Skip to content

Commit 8e0f14f

Browse files
Generate ske
1 parent 875e273 commit 8e0f14f

44 files changed

Lines changed: 202 additions & 144 deletions

Some content is hidden

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

services/ske/oas_commit

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

services/ske/src/stackit/ske/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/ske/src/stackit/ske/models/access.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.ske.models.idp import IDP
@@ -32,7 +33,8 @@ class Access(BaseModel):
3233
__properties: ClassVar[List[str]] = ["idp"]
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/ske/src/stackit/ske/models/acl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
StrictBool,
2525
StrictStr,
2626
)
27+
from pydantic_core import to_jsonable_python
2728
from typing_extensions import Annotated, Self
2829

2930

@@ -39,7 +40,8 @@ class ACL(BaseModel):
3940
__properties: ClassVar[List[str]] = ["allowedCidrs", "enabled"]
4041

4142
model_config = ConfigDict(
42-
populate_by_name=True,
43+
validate_by_name=True,
44+
validate_by_alias=True,
4345
validate_assignment=True,
4446
protected_namespaces=(),
4547
)
@@ -50,8 +52,7 @@ def to_str(self) -> str:
5052

5153
def to_json(self) -> str:
5254
"""Returns the JSON representation of the model using alias"""
53-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54-
return json.dumps(self.to_dict())
55+
return json.dumps(to_jsonable_python(self.to_dict()))
5556

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

services/ske/src/stackit/ske/models/availability_zone.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, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -30,7 +31,8 @@ class AvailabilityZone(BaseModel):
3031
__properties: ClassVar[List[str]] = ["name"]
3132

3233
model_config = ConfigDict(
33-
populate_by_name=True,
34+
validate_by_name=True,
35+
validate_by_alias=True,
3436
validate_assignment=True,
3537
protected_namespaces=(),
3638
)
@@ -41,8 +43,7 @@ def to_str(self) -> str:
4143

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

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

services/ske/src/stackit/ske/models/cluster.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 Annotated, Self
2223

2324
from stackit.ske.models.access import Access
@@ -57,7 +58,8 @@ class Cluster(BaseModel):
5758
]
5859

5960
model_config = ConfigDict(
60-
populate_by_name=True,
61+
validate_by_name=True,
62+
validate_by_alias=True,
6163
validate_assignment=True,
6264
protected_namespaces=(),
6365
)
@@ -68,8 +70,7 @@ def to_str(self) -> str:
6870

6971
def to_json(self) -> str:
7072
"""Returns the JSON representation of the model using alias"""
71-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
72-
return json.dumps(self.to_dict())
73+
return json.dumps(to_jsonable_python(self.to_dict()))
7374

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

services/ske/src/stackit/ske/models/cluster_error.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

@@ -34,7 +35,8 @@ class ClusterError(BaseModel):
3435
__properties: ClassVar[List[str]] = ["code", "message"]
3536

3637
model_config = ConfigDict(
37-
populate_by_name=True,
38+
validate_by_name=True,
39+
validate_by_alias=True,
3840
validate_assignment=True,
3941
protected_namespaces=(),
4042
)
@@ -45,8 +47,7 @@ def to_str(self) -> str:
4547

4648
def to_json(self) -> str:
4749
"""Returns the JSON representation of the model using alias"""
48-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49-
return json.dumps(self.to_dict())
50+
return json.dumps(to_jsonable_python(self.to_dict()))
5051

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

services/ske/src/stackit/ske/models/cluster_status.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
StrictStr,
2828
field_validator,
2929
)
30+
from pydantic_core import to_jsonable_python
3031
from typing_extensions import Self
3132

3233
from stackit.ske.models.cluster_error import ClusterError
@@ -88,7 +89,8 @@ def creation_time_change_year_zero_to_one(cls, value):
8889
return value
8990

9091
model_config = ConfigDict(
91-
populate_by_name=True,
92+
validate_by_name=True,
93+
validate_by_alias=True,
9294
validate_assignment=True,
9395
protected_namespaces=(),
9496
)
@@ -99,8 +101,7 @@ def to_str(self) -> str:
99101

100102
def to_json(self) -> str:
101103
"""Returns the JSON representation of the model using alias"""
102-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
103-
return json.dumps(self.to_dict())
104+
return json.dumps(to_jsonable_python(self.to_dict()))
104105

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

services/ske/src/stackit/ske/models/create_kubeconfig_payload.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

@@ -30,7 +31,8 @@ class CreateKubeconfigPayload(BaseModel):
3031
__properties: ClassVar[List[str]] = ["expirationSeconds"]
3132

3233
model_config = ConfigDict(
33-
populate_by_name=True,
34+
validate_by_name=True,
35+
validate_by_alias=True,
3436
validate_assignment=True,
3537
protected_namespaces=(),
3638
)
@@ -41,8 +43,7 @@ def to_str(self) -> str:
4143

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

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

services/ske/src/stackit/ske/models/create_or_update_cluster_payload.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
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Annotated, Self
2223

2324
from stackit.ske.models.access import Access
@@ -55,7 +56,8 @@ class CreateOrUpdateClusterPayload(BaseModel):
5556
]
5657

5758
model_config = ConfigDict(
58-
populate_by_name=True,
59+
validate_by_name=True,
60+
validate_by_alias=True,
5961
validate_assignment=True,
6062
protected_namespaces=(),
6163
)
@@ -66,8 +68,7 @@ def to_str(self) -> str:
6668

6769
def to_json(self) -> str:
6870
"""Returns the JSON representation of the model using alias"""
69-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
70-
return json.dumps(self.to_dict())
71+
return json.dumps(to_jsonable_python(self.to_dict()))
7172

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

0 commit comments

Comments
 (0)