diff --git a/services/loadbalancer/oas_commit b/services/loadbalancer/oas_commit index 36076afe8..b129c2291 100644 --- a/services/loadbalancer/oas_commit +++ b/services/loadbalancer/oas_commit @@ -1 +1 @@ -87a3ad63dec0a953ff5c6072ad9a15fddd8ec5f8 +98c11e0ee4834ddaaa474eccc437d234e6276a70 diff --git a/services/loadbalancer/src/stackit/loadbalancer/api_client.py b/services/loadbalancer/src/stackit/loadbalancer/api_client.py index 24f82624c..7587d4276 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/api_client.py +++ b/services/loadbalancer/src/stackit/loadbalancer/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/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py index 4b105af9a..0e8e4dd6e 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.http_health_checks import HttpHealthChecks @@ -66,6 +67,9 @@ def interval_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -76,6 +80,9 @@ def interval_jitter_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value @@ -86,12 +93,16 @@ def timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -102,8 +113,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/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py index c29d62b31..37e54e7f4 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,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/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py index 936daf15e..1c3b85479 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.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.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class CreateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] 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/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py index 49881d842..91562d70a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,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=(), ) @@ -156,8 +161,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/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py index 6557fcaf3..35a6d1aaf 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -63,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/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py index fd8589a85..80535204d 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.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.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class GetCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] 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/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py index 0c7b4dece..1ae5094fc 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py @@ -20,6 +20,7 @@ from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -65,6 +66,9 @@ def project_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -77,12 +81,16 @@ def region_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value): raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -93,8 +101,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/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py b/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py index ed8c61f67..8ae8ce244 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.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 @@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel): __properties: ClassVar[List[str]] = ["@type"] 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/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py index 06b06894d..f99746bea 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/http_health_checks.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 from stackit.loadbalancer.models.tls_config import TlsConfig @@ -36,7 +37,8 @@ class HttpHealthChecks(BaseModel): __properties: ClassVar[List[str]] = ["okStatuses", "path", "tls"] 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/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py index 5b35c9227..9e265f4df 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_credentials_response.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.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class ListCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credentials"] 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/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py index bd586cfc5..147f3b5ce 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_load_balancers_response.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.load_balancer import LoadBalancer @@ -43,12 +44,16 @@ def next_page_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -59,8 +64,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/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py index 70bcb8d6b..6ef87fd9e 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/list_plans_response.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.loadbalancer.models.plan_details import PlanDetails @@ -32,7 +33,8 @@ class ListPlansResponse(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/loadbalancer/src/stackit/loadbalancer/models/listener.py b/services/loadbalancer/src/stackit/loadbalancer/models/listener.py index 9161b9a79..96084a327 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/listener.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/listener.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.options_tcp import OptionsTCP @@ -78,7 +79,8 @@ def protocol_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=(), ) @@ -89,8 +91,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/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py index 966f829c9..5f4c80638 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,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=(), ) @@ -156,8 +161,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/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py index d61db3331..8b94401aa 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_error.py @@ -18,6 +18,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -62,7 +63,8 @@ def type_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=(), ) @@ -73,8 +75,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/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py index f6c58f69b..18778d168 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/load_balancer_options.py @@ -18,6 +18,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 from stackit.loadbalancer.models.loadbalancer_option_access_control import ( @@ -44,7 +45,8 @@ class LoadBalancerOptions(BaseModel): __properties: ClassVar[List[str]] = ["accessControl", "ephemeralAddress", "observability", "privateNetworkOnly"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -55,8 +57,7 @@ def to_str(self) -> str: def to_json(self) -> str: """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: diff --git a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py index 300ff1c12..800d75739 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_access_control.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 @@ -34,7 +35,8 @@ class LoadbalancerOptionAccessControl(BaseModel): __properties: ClassVar[List[str]] = ["allowedSourceRanges"] 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/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py index db99f1100..cbd83141b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_logs.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 @@ -39,7 +40,8 @@ class LoadbalancerOptionLogs(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] 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/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py index 79df3f633..9fadc03f5 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_metrics.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 @@ -39,7 +40,8 @@ class LoadbalancerOptionMetrics(BaseModel): __properties: ClassVar[List[str]] = ["credentialsRef", "pushUrl"] 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/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py index b3e8abac1..30f2f3a41 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/loadbalancer_option_observability.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.loadbalancer.models.loadbalancer_option_logs import LoadbalancerOptionLogs @@ -36,7 +37,8 @@ class LoadbalancerOptionObservability(BaseModel): __properties: ClassVar[List[str]] = ["logs", "metrics"] 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/loadbalancer/src/stackit/loadbalancer/models/network.py b/services/loadbalancer/src/stackit/loadbalancer/models/network.py index 00d2499de..d93e94f10 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/network.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/network.py @@ -20,6 +20,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 Self @@ -41,6 +42,9 @@ def network_id_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", value): raise ValueError( r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/" @@ -60,7 +64,8 @@ def role_validate_enum(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -71,8 +76,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/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py b/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py index 1963f89bf..8e93b3f3d 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/options_tcp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,12 +41,16 @@ def idle_timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,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/loadbalancer/src/stackit/loadbalancer/models/options_udp.py b/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py index 80c8e8129..3ca2ac87b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/options_udp.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -40,12 +41,16 @@ def idle_timeout_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value): raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -56,8 +61,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/loadbalancer/src/stackit/loadbalancer/models/plan_details.py b/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py index dd9639bf3..ea97fdf45 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/plan_details.py @@ -18,6 +18,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 @@ -39,7 +40,8 @@ class PlanDetails(BaseModel): __properties: ClassVar[List[str]] = ["description", "flavorName", "maxConnections", "name", "planId", "region"] 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/loadbalancer/src/stackit/loadbalancer/models/security_group.py b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py index 4bc8b6312..cc983012a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/security_group.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/security_group.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 @@ -31,7 +32,8 @@ class SecurityGroup(BaseModel): __properties: ClassVar[List[str]] = ["id", "name"] 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/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py b/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py index 031d8d9bd..cc26d5f76 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/server_name_indicator.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 ServerNameIndicator(BaseModel): __properties: ClassVar[List[str]] = ["name"] 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/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py b/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py index 49c96fbb9..12f41132a 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/session_persistence.py @@ -18,6 +18,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 @@ -34,7 +35,8 @@ class SessionPersistence(BaseModel): __properties: ClassVar[List[str]] = ["useSourceIpAddress"] 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/loadbalancer/src/stackit/loadbalancer/models/status.py b/services/loadbalancer/src/stackit/loadbalancer/models/status.py index dc73b49b8..f546fd880 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/status.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/status.py @@ -18,6 +18,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.loadbalancer.models.google_protobuf_any import GoogleProtobufAny @@ -43,7 +44,8 @@ class Status(BaseModel): __properties: ClassVar[List[str]] = ["code", "details", "message"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -54,8 +56,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/loadbalancer/src/stackit/loadbalancer/models/target.py b/services/loadbalancer/src/stackit/loadbalancer/models/target.py index d54a34059..108a9dec7 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/target.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/target.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -39,6 +40,9 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$", value): raise ValueError( r"must validate the regular expression /^[0-9a-zA-Z](?:(?:[0-9a-zA-Z]|-){0,61}[0-9a-zA-Z])?$/" @@ -46,7 +50,8 @@ def display_name_validate_regular_expression(cls, value): return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -57,8 +62,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/loadbalancer/src/stackit/loadbalancer/models/target_pool.py b/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py index 69e47e01a..dce51d54b 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/target_pool.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,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/loadbalancer/src/stackit/loadbalancer/models/tls_config.py b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py index 812f4dba4..cb96bc7d8 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/tls_config.py @@ -24,6 +24,7 @@ StrictBool, StrictStr, ) +from pydantic_core import to_jsonable_python from typing_extensions import Self @@ -49,7 +50,8 @@ class TlsConfig(BaseModel): __properties: ClassVar[List[str]] = ["customCa", "enabled", "skipCertificateValidation"] model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -60,8 +62,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/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py index 7892a5710..8b4ba419c 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -62,8 +67,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/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py index a0837b6cb..7ed14eb75 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_credentials_response.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.loadbalancer.models.credentials_response import CredentialsResponse @@ -32,7 +33,8 @@ class UpdateCredentialsResponse(BaseModel): __properties: ClassVar[List[str]] = ["credential"] 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/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py index 33a328942..139ce4f70 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_load_balancer_payload.py @@ -26,6 +26,7 @@ StrictStr, field_validator, ) +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.listener import Listener @@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value @@ -145,7 +149,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=(), ) @@ -156,8 +161,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/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py b/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py index c513ebf4f..053577c25 100644 --- a/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py +++ b/services/loadbalancer/src/stackit/loadbalancer/models/update_target_pool_payload.py @@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Set from pydantic import BaseModel, ConfigDict, Field, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self from stackit.loadbalancer.models.active_health_check import ActiveHealthCheck @@ -50,12 +51,16 @@ def name_validate_regular_expression(cls, value): if value is None: return value + if not isinstance(value, str): + value = str(value) + if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value): raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/") return value model_config = ConfigDict( - populate_by_name=True, + validate_by_name=True, + validate_by_alias=True, validate_assignment=True, protected_namespaces=(), ) @@ -66,8 +71,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]: