From 1ab4dad22340a71178ee30f97bcc11a6f8266783 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 11 May 2026 10:17:32 +0000 Subject: [PATCH] Generate edge --- services/edge/oas_commit | 2 +- services/edge/src/stackit/edge/__init__.py | 4 + .../edge/src/stackit/edge/api/default_api.py | 235 ++++++++++++++++++ services/edge/src/stackit/edge/api_client.py | 32 ++- .../edge/src/stackit/edge/models/__init__.py | 1 + .../src/stackit/edge/models/bad_request.py | 7 +- .../edge/models/create_instance_payload.py | 7 +- .../edge/src/stackit/edge/models/instance.py | 7 +- .../src/stackit/edge/models/instance_list.py | 7 +- .../src/stackit/edge/models/kubeconfig.py | 7 +- .../edge/models/kubernetes_release_list.py | 82 ++++++ services/edge/src/stackit/edge/models/plan.py | 7 +- .../edge/src/stackit/edge/models/plan_list.py | 7 +- .../edge/src/stackit/edge/models/token.py | 7 +- .../edge/models/unauthorized_request.py | 7 +- .../models/update_instance_by_name_payload.py | 7 +- .../edge/models/update_instance_payload.py | 7 +- services/edge/src/stackit/edge/models/user.py | 7 +- 18 files changed, 386 insertions(+), 54 deletions(-) create mode 100644 services/edge/src/stackit/edge/models/kubernetes_release_list.py diff --git a/services/edge/oas_commit b/services/edge/oas_commit index cca6a5e9a..b129c2291 100644 --- a/services/edge/oas_commit +++ b/services/edge/oas_commit @@ -1 +1 @@ -95de5cba3201a683657cb472d5fa30aa768f19cc +98c11e0ee4834ddaaa474eccc437d234e6276a70 diff --git a/services/edge/src/stackit/edge/__init__.py b/services/edge/src/stackit/edge/__init__.py index 267315f0b..93d93f2ad 100644 --- a/services/edge/src/stackit/edge/__init__.py +++ b/services/edge/src/stackit/edge/__init__.py @@ -33,6 +33,7 @@ "Instance", "InstanceList", "Kubeconfig", + "KubernetesReleaseList", "Plan", "PlanList", "Token", @@ -64,6 +65,9 @@ from stackit.edge.models.instance import Instance as Instance from stackit.edge.models.instance_list import InstanceList as InstanceList from stackit.edge.models.kubeconfig import Kubeconfig as Kubeconfig +from stackit.edge.models.kubernetes_release_list import ( + KubernetesReleaseList as KubernetesReleaseList, +) from stackit.edge.models.plan import Plan as Plan from stackit.edge.models.plan_list import PlanList as PlanList from stackit.edge.models.token import Token as Token diff --git a/services/edge/src/stackit/edge/api/default_api.py b/services/edge/src/stackit/edge/api/default_api.py index 665ce3fde..ab1c8cc18 100644 --- a/services/edge/src/stackit/edge/api/default_api.py +++ b/services/edge/src/stackit/edge/api/default_api.py @@ -30,6 +30,7 @@ from stackit.edge.models.instance import Instance from stackit.edge.models.instance_list import InstanceList from stackit.edge.models.kubeconfig import Kubeconfig +from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList from stackit.edge.models.plan_list import PlanList from stackit.edge.models.token import Token from stackit.edge.models.update_instance_by_name_payload import ( @@ -2627,6 +2628,240 @@ def _get_token_by_instance_name_serialize( _request_auth=_request_auth, ) + @validate_call + def list_compatible_kubernetes_releases( + self, + talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> KubernetesReleaseList: + """list_compatible_kubernetes_releases + + + :param talos_version: The name of the Talos release. (required) + :type talos_version: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_compatible_kubernetes_releases_serialize( + talos_version=talos_version, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KubernetesReleaseList", + "400": "BadRequest", + "404": None, + "500": None, + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_compatible_kubernetes_releases_with_http_info( + self, + talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[KubernetesReleaseList]: + """list_compatible_kubernetes_releases + + + :param talos_version: The name of the Talos release. (required) + :type talos_version: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_compatible_kubernetes_releases_serialize( + talos_version=talos_version, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KubernetesReleaseList", + "400": "BadRequest", + "404": None, + "500": None, + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_compatible_kubernetes_releases_without_preload_content( + self, + talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """list_compatible_kubernetes_releases + + + :param talos_version: The name of the Talos release. (required) + :type talos_version: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_compatible_kubernetes_releases_serialize( + talos_version=talos_version, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "KubernetesReleaseList", + "400": "BadRequest", + "404": None, + "500": None, + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_compatible_kubernetes_releases_serialize( + self, + talos_version, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if talos_version is not None: + + _query_params.append(("talosVersion", talos_version)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1beta1/listcompatiblekubernetesreleases", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call def list_instances( self, diff --git a/services/edge/src/stackit/edge/api_client.py b/services/edge/src/stackit/edge/api_client.py index 57b6ea31a..a22becd9d 100644 --- a/services/edge/src/stackit/edge/api_client.py +++ b/services/edge/src/stackit/edge/api_client.py @@ -66,6 +66,7 @@ class ApiClient: "date": datetime.date, "datetime": datetime.datetime, "decimal": decimal.Decimal, + "UUID": uuid.UUID, "object": object, } _pool = None @@ -265,7 +266,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) @@ -326,25 +327,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. @@ -417,6 +413,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/edge/src/stackit/edge/models/__init__.py b/services/edge/src/stackit/edge/models/__init__.py index ae6007c0b..44c1552e8 100644 --- a/services/edge/src/stackit/edge/models/__init__.py +++ b/services/edge/src/stackit/edge/models/__init__.py @@ -18,6 +18,7 @@ from stackit.edge.models.instance import Instance from stackit.edge.models.instance_list import InstanceList from stackit.edge.models.kubeconfig import Kubeconfig +from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList from stackit.edge.models.plan import Plan from stackit.edge.models.plan_list import PlanList from stackit.edge.models.token import Token diff --git a/services/edge/src/stackit/edge/models/bad_request.py b/services/edge/src/stackit/edge/models/bad_request.py index 6f9b8d5e5..bd09fdef7 100644 --- a/services/edge/src/stackit/edge/models/bad_request.py +++ b/services/edge/src/stackit/edge/models/bad_request.py @@ -18,6 +18,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 BadRequest(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] 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/edge/src/stackit/edge/models/create_instance_payload.py b/services/edge/src/stackit/edge/models/create_instance_payload.py index b497a592e..21d9d3914 100644 --- a/services/edge/src/stackit/edge/models/create_instance_payload.py +++ b/services/edge/src/stackit/edge/models/create_instance_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -37,7 +38,8 @@ class CreateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "displayName", "planId"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -48,8 +50,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/edge/src/stackit/edge/models/instance.py b/services/edge/src/stackit/edge/models/instance.py index a6589c2bb..453c92102 100644 --- a/services/edge/src/stackit/edge/models/instance.py +++ b/services/edge/src/stackit/edge/models/instance.py @@ -21,6 +21,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -73,7 +74,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=(), ) @@ -84,8 +86,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/edge/src/stackit/edge/models/instance_list.py b/services/edge/src/stackit/edge/models/instance_list.py index 644929223..1d5cc25d2 100644 --- a/services/edge/src/stackit/edge/models/instance_list.py +++ b/services/edge/src/stackit/edge/models/instance_list.py @@ -18,6 +18,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.edge.models.instance import Instance @@ -32,7 +33,8 @@ class InstanceList(BaseModel): __properties: ClassVar[List[str]] = ["instances"] 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/edge/src/stackit/edge/models/kubeconfig.py b/services/edge/src/stackit/edge/models/kubeconfig.py index ef2269570..b9f2139cd 100644 --- a/services/edge/src/stackit/edge/models/kubeconfig.py +++ b/services/edge/src/stackit/edge/models/kubeconfig.py @@ -18,6 +18,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 @@ -30,7 +31,8 @@ class Kubeconfig(BaseModel): __properties: ClassVar[List[str]] = ["kubeconfig"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,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/edge/src/stackit/edge/models/kubernetes_release_list.py b/services/edge/src/stackit/edge/models/kubernetes_release_list.py new file mode 100644 index 000000000..c62f0cc24 --- /dev/null +++ b/services/edge/src/stackit/edge/models/kubernetes_release_list.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + STACKIT Edge Cloud API + + This API provides endpoints for managing STACKIT Edge Cloud instances. + + The version of the OpenAPI document: 1beta1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +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 + + +class KubernetesReleaseList(BaseModel): + """ + A list of compatible Kubernetes releases. + """ # noqa: E501 + + k8s_releases: List[StrictStr] = Field(description="Array of Kubernetes version strings.") + __properties: ClassVar[List[str]] = ["k8s_releases"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of KubernetesReleaseList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of KubernetesReleaseList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"k8s_releases": obj.get("k8s_releases")}) + return _obj diff --git a/services/edge/src/stackit/edge/models/plan.py b/services/edge/src/stackit/edge/models/plan.py index 133820056..0e22a1b00 100644 --- a/services/edge/src/stackit/edge/models/plan.py +++ b/services/edge/src/stackit/edge/models/plan.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -39,7 +40,8 @@ class Plan(BaseModel): __properties: ClassVar[List[str]] = ["description", "id", "maxEdgeHosts", "minEdgeHosts", "name"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -50,8 +52,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/edge/src/stackit/edge/models/plan_list.py b/services/edge/src/stackit/edge/models/plan_list.py index 649684919..730f5d7c7 100644 --- a/services/edge/src/stackit/edge/models/plan_list.py +++ b/services/edge/src/stackit/edge/models/plan_list.py @@ -18,6 +18,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.edge.models.plan import Plan @@ -32,7 +33,8 @@ class PlanList(BaseModel): __properties: ClassVar[List[str]] = ["validPlans"] 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/edge/src/stackit/edge/models/token.py b/services/edge/src/stackit/edge/models/token.py index 41f6ae88e..2bbb1f28d 100644 --- a/services/edge/src/stackit/edge/models/token.py +++ b/services/edge/src/stackit/edge/models/token.py @@ -18,6 +18,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 @@ -30,7 +31,8 @@ class Token(BaseModel): __properties: ClassVar[List[str]] = ["token"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -41,8 +43,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/edge/src/stackit/edge/models/unauthorized_request.py b/services/edge/src/stackit/edge/models/unauthorized_request.py index 5ef8af622..c61390c79 100644 --- a/services/edge/src/stackit/edge/models/unauthorized_request.py +++ b/services/edge/src/stackit/edge/models/unauthorized_request.py @@ -18,6 +18,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 UnauthorizedRequest(BaseModel): __properties: ClassVar[List[str]] = ["code", "message"] 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/edge/src/stackit/edge/models/update_instance_by_name_payload.py b/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py index 6c4293086..ebd92c671 100644 --- a/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py +++ b/services/edge/src/stackit/edge/models/update_instance_by_name_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class UpdateInstanceByNamePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "planId"] 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/edge/src/stackit/edge/models/update_instance_payload.py b/services/edge/src/stackit/edge/models/update_instance_payload.py index 1304f4c90..f78917d9c 100644 --- a/services/edge/src/stackit/edge/models/update_instance_payload.py +++ b/services/edge/src/stackit/edge/models/update_instance_payload.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -36,7 +37,8 @@ class UpdateInstancePayload(BaseModel): __properties: ClassVar[List[str]] = ["description", "planId"] 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/edge/src/stackit/edge/models/user.py b/services/edge/src/stackit/edge/models/user.py index 952b1bb3b..7c6a7726c 100644 --- a/services/edge/src/stackit/edge/models/user.py +++ b/services/edge/src/stackit/edge/models/user.py @@ -19,6 +19,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -32,7 +33,8 @@ class User(BaseModel): __properties: ClassVar[List[str]] = ["email", "internalId"] 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]: