From 62622406d0668e7108f33853e5d7631d2d371bb3 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Tue, 12 May 2026 12:40:36 +0000 Subject: [PATCH] Generate serverupdate --- services/serverupdate/oas_commit | 2 +- .../src/stackit/serverupdate/api_client.py | 32 +++++++++---------- .../models/create_update_payload.py | 7 ++-- .../models/create_update_schedule_payload.py | 7 ++-- .../models/enable_service_resource_payload.py | 7 ++-- .../serverupdate/models/error_response.py | 7 ++-- .../models/get_update_policies_response.py | 7 ++-- .../models/get_update_schedules_response.py | 7 ++-- .../models/get_update_service_response.py | 7 ++-- .../models/get_updates_list_response.py | 7 ++-- .../src/stackit/serverupdate/models/update.py | 7 ++-- .../serverupdate/models/update_policy.py | 7 ++-- .../serverupdate/models/update_schedule.py | 7 ++-- .../models/update_schedule_create_request.py | 7 ++-- .../models/update_update_schedule_payload.py | 7 ++-- 15 files changed, 68 insertions(+), 57 deletions(-) diff --git a/services/serverupdate/oas_commit b/services/serverupdate/oas_commit index e3713dde3..f4a2ce25c 100644 --- a/services/serverupdate/oas_commit +++ b/services/serverupdate/oas_commit @@ -1 +1 @@ -0e64886dd0847341800d7191ed193b75413be998 +8f43ed707da765654e4427642c9d978f80d504e1 diff --git a/services/serverupdate/src/stackit/serverupdate/api_client.py b/services/serverupdate/src/stackit/serverupdate/api_client.py index 5e4603fbd..c1fa148b3 100644 --- a/services/serverupdate/src/stackit/serverupdate/api_client.py +++ b/services/serverupdate/src/stackit/serverupdate/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")): # noqa: B009 + 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/serverupdate/src/stackit/serverupdate/models/create_update_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py index 011869f9c..d8379657d 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.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 Annotated, Self @@ -35,7 +36,8 @@ class CreateUpdatePayload(BaseModel): __properties: ClassVar[List[str]] = ["backupBeforeUpdate", "maintenanceWindow"] 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/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py index 64f4651c2..c8c0299ec 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class CreateUpdateSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,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/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py b/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py index 25b01c9e9..61d463767 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/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]] = ["updatePolicyId"] 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/serverupdate/src/stackit/serverupdate/models/error_response.py b/services/serverupdate/src/stackit/serverupdate/models/error_response.py index 15adb7bd8..d4b939156 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/error_response.py +++ b/services/serverupdate/src/stackit/serverupdate/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/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py index ec274af33..6864dae44 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_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.serverupdate.models.update_policy import UpdatePolicy @@ -33,7 +34,8 @@ class GetUpdatePoliciesResponse(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/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py index 902896790..ebe805a31 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_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.serverupdate.models.update_schedule import UpdateSchedule @@ -33,7 +34,8 @@ class GetUpdateSchedulesResponse(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/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py index a6f7303ab..16054fca4 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_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 GetUpdateServiceResponse(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/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py index cef6fbf93..107d9bd41 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_updates_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.serverupdate.models.update import Update @@ -33,7 +34,8 @@ class GetUpdatesListResponse(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/serverupdate/src/stackit/serverupdate/models/update.py b/services/serverupdate/src/stackit/serverupdate/models/update.py index 214052e15..10de83a0c 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update.py +++ b/services/serverupdate/src/stackit/serverupdate/models/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 @@ -45,7 +46,8 @@ class Update(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,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/serverupdate/src/stackit/serverupdate/models/update_policy.py b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py index 75d93d2a5..5c68697e0 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_policy.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -59,7 +60,8 @@ class UpdatePolicy(BaseModel): ] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -70,8 +72,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/serverupdate/src/stackit/serverupdate/models/update_schedule.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py index 19632b3d3..559c01793 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py @@ -26,6 +26,7 @@ StrictInt, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,7 +48,8 @@ class UpdateSchedule(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule", "id"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -58,8 +60,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/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py index bafba1111..dcfdd51b8 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class UpdateScheduleCreateRequest(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,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/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py index 1c6f00a76..ec46a726a 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py @@ -25,6 +25,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -45,7 +46,8 @@ class UpdateUpdateSchedulePayload(BaseModel): __properties: ClassVar[List[str]] = ["enabled", "maintenanceWindow", "name", "rrule"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +58,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]: