Skip to content

Commit f17c193

Browse files
Generate alb
1 parent 875e273 commit f17c193

42 files changed

Lines changed: 233 additions & 138 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

services/alb/oas_commit

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

services/alb/src/stackit/alb/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")):
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/alb/src/stackit/alb/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.alb.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/alb/src/stackit/alb/models/certificate_config.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

@@ -32,7 +33,8 @@ class CertificateConfig(BaseModel):
3233
__properties: ClassVar[List[str]] = ["certificateIds"]
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/alb/src/stackit/alb/models/cookie_persistence.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

@@ -40,12 +41,16 @@ def ttl_validate_regular_expression(cls, value):
4041
if value is None:
4142
return value
4243

44+
if not isinstance(value, str):
45+
value = str(value)
46+
4347
if not re.match(r"^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$", value):
4448
raise ValueError(r"must validate the regular expression /^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$/")
4549
return value
4650

4751
model_config = ConfigDict(
48-
populate_by_name=True,
52+
validate_by_name=True,
53+
validate_by_alias=True,
4954
validate_assignment=True,
5055
protected_namespaces=(),
5156
)
@@ -56,8 +61,7 @@ def to_str(self) -> str:
5661

5762
def to_json(self) -> str:
5863
"""Returns the JSON representation of the model using alias"""
59-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60-
return json.dumps(self.to_dict())
64+
return json.dumps(to_jsonable_python(self.to_dict()))
6165

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

services/alb/src/stackit/alb/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/alb/src/stackit/alb/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.alb.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/alb/src/stackit/alb/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.alb.models.listener import Listener
@@ -123,6 +124,9 @@ def name_validate_regular_expression(cls, value):
123124
if value is None:
124125
return value
125126

127+
if not isinstance(value, str):
128+
value = str(value)
129+
126130
if not re.match(r"^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$", value):
127131
raise ValueError(r"must validate the regular expression /^[0-9a-z](?:(?:[0-9a-z]|-){0,61}[0-9a-z])?$/")
128132
return value
@@ -142,7 +146,8 @@ def status_validate_enum(cls, value):
142146
return value
143147

144148
model_config = ConfigDict(
145-
populate_by_name=True,
149+
validate_by_name=True,
150+
validate_by_alias=True,
146151
validate_assignment=True,
147152
protected_namespaces=(),
148153
)
@@ -153,8 +158,7 @@ def to_str(self) -> str:
153158

154159
def to_json(self) -> str:
155160
"""Returns the JSON representation of the model using alias"""
156-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
157-
return json.dumps(self.to_dict())
161+
return json.dumps(to_jsonable_python(self.to_dict()))
158162

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

services/alb/src/stackit/alb/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/alb/src/stackit/alb/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.alb.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]:

0 commit comments

Comments
 (0)