Skip to content

Commit d04a216

Browse files
Generate loadbalancer
1 parent 875e273 commit d04a216

37 files changed

Lines changed: 210 additions & 123 deletions

services/loadbalancer/oas_commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
87a3ad63dec0a953ff5c6072ad9a15fddd8ec5f8
1+
8f43ed707da765654e4427642c9d978f80d504e1

services/loadbalancer/src/stackit/loadbalancer/api_client.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ApiClient:
6666
"date": datetime.date,
6767
"datetime": datetime.datetime,
6868
"decimal": decimal.Decimal,
69+
"UUID": uuid.UUID,
6970
"object": object,
7071
}
7172
_pool = None
@@ -265,7 +266,7 @@ def response_deserialize(
265266
response_text = None
266267
return_data = None
267268
try:
268-
if response_type == "bytearray":
269+
if response_type in ("bytearray", "bytes"):
269270
return_data = response_data.data
270271
elif response_type == "file":
271272
return_data = self.__deserialize_file(response_data)
@@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj):
326327
return obj.isoformat()
327328
elif isinstance(obj, decimal.Decimal):
328329
return str(obj)
329-
330330
elif isinstance(obj, dict):
331-
obj_dict = obj
331+
return {key: self.sanitize_for_serialization(val) for key, val in obj.items()}
332+
333+
# Convert model obj to dict except
334+
# attributes `openapi_types`, `attribute_map`
335+
# and attributes which value is not None.
336+
# Convert attribute name to json key in
337+
# model definition for request.
338+
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
339+
obj_dict = obj.to_dict()
332340
else:
333-
# Convert model obj to dict except
334-
# attributes `openapi_types`, `attribute_map`
335-
# and attributes which value is not None.
336-
# Convert attribute name to json key in
337-
# model definition for request.
338-
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
339-
obj_dict = obj.to_dict()
340-
else:
341-
obj_dict = obj.__dict__
342-
343-
if isinstance(obj_dict, list):
344-
# 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
345-
return self.sanitize_for_serialization(obj_dict)
341+
obj_dict = obj.__dict__
346342

347-
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
343+
return self.sanitize_for_serialization(obj_dict)
348344

349345
def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
350346
"""Deserializes response into an object.
@@ -417,6 +413,8 @@ def __deserialize(self, data, klass):
417413
return self.__deserialize_datetime(data)
418414
elif klass is decimal.Decimal:
419415
return decimal.Decimal(data)
416+
elif klass is uuid.UUID:
417+
return uuid.UUID(data)
420418
elif issubclass(klass, Enum):
421419
return self.__deserialize_enum(data, klass)
422420
else:

services/loadbalancer/src/stackit/loadbalancer/models/active_health_check.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field, StrictInt, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425
from stackit.loadbalancer.models.http_health_checks import HttpHealthChecks
@@ -66,6 +67,9 @@ def interval_validate_regular_expression(cls, value):
6667
if value is None:
6768
return value
6869

70+
if not isinstance(value, str):
71+
value = str(value)
72+
6973
if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
7074
raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
7175
return value
@@ -76,6 +80,9 @@ def interval_jitter_validate_regular_expression(cls, value):
7680
if value is None:
7781
return value
7882

83+
if not isinstance(value, str):
84+
value = str(value)
85+
7986
if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
8087
raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
8188
return value
@@ -86,12 +93,16 @@ def timeout_validate_regular_expression(cls, value):
8693
if value is None:
8794
return value
8895

96+
if not isinstance(value, str):
97+
value = str(value)
98+
8999
if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
90100
raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
91101
return value
92102

93103
model_config = ConfigDict(
94-
populate_by_name=True,
104+
validate_by_name=True,
105+
validate_by_alias=True,
95106
validate_assignment=True,
96107
protected_namespaces=(),
97108
)
@@ -102,8 +113,7 @@ def to_str(self) -> str:
102113

103114
def to_json(self) -> str:
104115
"""Returns the JSON representation of the model using alias"""
105-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
106-
return json.dumps(self.to_dict())
116+
return json.dumps(to_jsonable_python(self.to_dict()))
107117

108118
@classmethod
109119
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_payload.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -46,12 +47,16 @@ def display_name_validate_regular_expression(cls, value):
4647
if value is None:
4748
return value
4849

50+
if not isinstance(value, str):
51+
value = str(value)
52+
4953
if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$", value):
5054
raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,251}[0-9a-z])?$/")
5155
return value
5256

5357
model_config = ConfigDict(
54-
populate_by_name=True,
58+
validate_by_name=True,
59+
validate_by_alias=True,
5560
validate_assignment=True,
5661
protected_namespaces=(),
5762
)
@@ -62,8 +67,7 @@ def to_str(self) -> str:
6267

6368
def to_json(self) -> str:
6469
"""Returns the JSON representation of the model using alias"""
65-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66-
return json.dumps(self.to_dict())
70+
return json.dumps(to_jsonable_python(self.to_dict()))
6771

6872
@classmethod
6973
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/create_credentials_response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Any, ClassVar, Dict, List, Optional, Set
1919

2020
from pydantic import BaseModel, ConfigDict
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.loadbalancer.models.credentials_response import CredentialsResponse
@@ -32,7 +33,8 @@ class CreateCredentialsResponse(BaseModel):
3233
__properties: ClassVar[List[str]] = ["credential"]
3334

3435
model_config = ConfigDict(
35-
populate_by_name=True,
36+
validate_by_name=True,
37+
validate_by_alias=True,
3638
validate_assignment=True,
3739
protected_namespaces=(),
3840
)
@@ -43,8 +45,7 @@ def to_str(self) -> str:
4345

4446
def to_json(self) -> str:
4547
"""Returns the JSON representation of the model using alias"""
46-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47-
return json.dumps(self.to_dict())
48+
return json.dumps(to_jsonable_python(self.to_dict()))
4849

4950
@classmethod
5051
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/create_load_balancer_payload.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
StrictStr,
2727
field_validator,
2828
)
29+
from pydantic_core import to_jsonable_python
2930
from typing_extensions import Annotated, Self
3031

3132
from stackit.loadbalancer.models.listener import Listener
@@ -126,6 +127,9 @@ def name_validate_regular_expression(cls, value):
126127
if value is None:
127128
return value
128129

130+
if not isinstance(value, str):
131+
value = str(value)
132+
129133
if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value):
130134
raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/")
131135
return value
@@ -145,7 +149,8 @@ def status_validate_enum(cls, value):
145149
return value
146150

147151
model_config = ConfigDict(
148-
populate_by_name=True,
152+
validate_by_name=True,
153+
validate_by_alias=True,
149154
validate_assignment=True,
150155
protected_namespaces=(),
151156
)
@@ -156,8 +161,7 @@ def to_str(self) -> str:
156161

157162
def to_json(self) -> str:
158163
"""Returns the JSON representation of the model using alias"""
159-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
160-
return json.dumps(self.to_dict())
164+
return json.dumps(to_jsonable_python(self.to_dict()))
161165

162166
@classmethod
163167
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/credentials_response.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

2121
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -47,12 +48,16 @@ def display_name_validate_regular_expression(cls, value):
4748
if value is None:
4849
return value
4950

51+
if not isinstance(value, str):
52+
value = str(value)
53+
5054
if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value):
5155
raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/")
5256
return value
5357

5458
model_config = ConfigDict(
55-
populate_by_name=True,
59+
validate_by_name=True,
60+
validate_by_alias=True,
5661
validate_assignment=True,
5762
protected_namespaces=(),
5863
)
@@ -63,8 +68,7 @@ def to_str(self) -> str:
6368

6469
def to_json(self) -> str:
6570
"""Returns the JSON representation of the model using alias"""
66-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
67-
return json.dumps(self.to_dict())
71+
return json.dumps(to_jsonable_python(self.to_dict()))
6872

6973
@classmethod
7074
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/get_credentials_response.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Any, ClassVar, Dict, List, Optional, Set
1919

2020
from pydantic import BaseModel, ConfigDict
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.loadbalancer.models.credentials_response import CredentialsResponse
@@ -32,7 +33,8 @@ class GetCredentialsResponse(BaseModel):
3233
__properties: ClassVar[List[str]] = ["credential"]
3334

3435
model_config = ConfigDict(
35-
populate_by_name=True,
36+
validate_by_name=True,
37+
validate_by_alias=True,
3638
validate_assignment=True,
3739
protected_namespaces=(),
3840
)
@@ -43,8 +45,7 @@ def to_str(self) -> str:
4345

4446
def to_json(self) -> str:
4547
"""Returns the JSON representation of the model using alias"""
46-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47-
return json.dumps(self.to_dict())
48+
return json.dumps(to_jsonable_python(self.to_dict()))
4849

4950
@classmethod
5051
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/get_quota_response.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from uuid import UUID
2121

2222
from pydantic import BaseModel, ConfigDict, Field, field_validator
23+
from pydantic_core import to_jsonable_python
2324
from typing_extensions import Annotated, Self
2425

2526

@@ -65,6 +66,9 @@ def project_id_validate_regular_expression(cls, value):
6566
if value is None:
6667
return value
6768

69+
if not isinstance(value, str):
70+
value = str(value)
71+
6872
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):
6973
raise ValueError(
7074
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):
7781
if value is None:
7882
return value
7983

84+
if not isinstance(value, str):
85+
value = str(value)
86+
8087
if not re.match(r"^[a-z]{2,4}[0-9]{2}$", value):
8188
raise ValueError(r"must validate the regular expression /^[a-z]{2,4}[0-9]{2}$/")
8289
return value
8390

8491
model_config = ConfigDict(
85-
populate_by_name=True,
92+
validate_by_name=True,
93+
validate_by_alias=True,
8694
validate_assignment=True,
8795
protected_namespaces=(),
8896
)
@@ -93,8 +101,7 @@ def to_str(self) -> str:
93101

94102
def to_json(self) -> str:
95103
"""Returns the JSON representation of the model using alias"""
96-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
97-
return json.dumps(self.to_dict())
104+
return json.dumps(to_jsonable_python(self.to_dict()))
98105

99106
@classmethod
100107
def from_json(cls, json_str: str) -> Optional[Self]:

services/loadbalancer/src/stackit/loadbalancer/models/google_protobuf_any.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Any, ClassVar, Dict, List, Optional, Set
1919

2020
from pydantic import BaseModel, ConfigDict, Field, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -31,7 +32,8 @@ class GoogleProtobufAny(BaseModel):
3132
__properties: ClassVar[List[str]] = ["@type"]
3233

3334
model_config = ConfigDict(
34-
populate_by_name=True,
35+
validate_by_name=True,
36+
validate_by_alias=True,
3537
validate_assignment=True,
3638
protected_namespaces=(),
3739
)
@@ -42,8 +44,7 @@ def to_str(self) -> str:
4244

4345
def to_json(self) -> str:
4446
"""Returns the JSON representation of the model using alias"""
45-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46-
return json.dumps(self.to_dict())
47+
return json.dumps(to_jsonable_python(self.to_dict()))
4748

4849
@classmethod
4950
def from_json(cls, json_str: str) -> Optional[Self]:

0 commit comments

Comments
 (0)