Skip to content

Commit 59a3715

Browse files
Generate sfs
1 parent 875e273 commit 59a3715

53 files changed

Lines changed: 220 additions & 171 deletions

File tree

Some content is hidden

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

services/sfs/oas_commit

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

services/sfs/src/stackit/sfs/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/sfs/src/stackit/sfs/models/create_resource_pool_payload.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
StrictInt,
2626
StrictStr,
2727
)
28+
from pydantic_core import to_jsonable_python
2829
from typing_extensions import Self
2930

3031

@@ -67,7 +68,8 @@ class CreateResourcePoolPayload(BaseModel):
6768
]
6869

6970
model_config = ConfigDict(
70-
populate_by_name=True,
71+
validate_by_name=True,
72+
validate_by_alias=True,
7173
validate_assignment=True,
7274
protected_namespaces=(),
7375
)
@@ -78,8 +80,7 @@ def to_str(self) -> str:
7880

7981
def to_json(self) -> str:
8082
"""Returns the JSON representation of the model using alias"""
81-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
82-
return json.dumps(self.to_dict())
83+
return json.dumps(to_jsonable_python(self.to_dict()))
8384

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

services/sfs/src/stackit/sfs/models/create_resource_pool_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, Field
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.sfs.models.resource_pool import ResourcePool
@@ -34,7 +35,8 @@ class CreateResourcePoolResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["resourcePool"]
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/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_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, StrictInt, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -38,7 +39,8 @@ class CreateResourcePoolSnapshotPayload(BaseModel):
3839
__properties: ClassVar[List[str]] = ["comment", "name", "snaplockRetentionHours"]
3940

4041
model_config = ConfigDict(
41-
populate_by_name=True,
42+
validate_by_name=True,
43+
validate_by_alias=True,
4244
validate_assignment=True,
4345
protected_namespaces=(),
4446
)
@@ -49,8 +51,7 @@ def to_str(self) -> str:
4951

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

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

services/sfs/src/stackit/sfs/models/create_resource_pool_snapshot_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, Field
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.sfs.models.resource_pool_snapshot import ResourcePoolSnapshot
@@ -34,7 +35,8 @@ class CreateResourcePoolSnapshotResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["resourcePoolSnapshot"]
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/sfs/src/stackit/sfs/models/create_share_export_policy_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
from stackit.sfs.models.create_share_export_policy_request_rule import (
@@ -42,7 +43,8 @@ class CreateShareExportPolicyPayload(BaseModel):
4243
__properties: ClassVar[List[str]] = ["labels", "name", "rules"]
4344

4445
model_config = ConfigDict(
45-
populate_by_name=True,
46+
validate_by_name=True,
47+
validate_by_alias=True,
4648
validate_assignment=True,
4749
protected_namespaces=(),
4850
)
@@ -53,8 +55,7 @@ def to_str(self) -> str:
5355

5456
def to_json(self) -> str:
5557
"""Returns the JSON representation of the model using alias"""
56-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
57-
return json.dumps(self.to_dict())
58+
return json.dumps(to_jsonable_python(self.to_dict()))
5859

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

services/sfs/src/stackit/sfs/models/create_share_export_policy_request_rule.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
StrictInt,
2626
StrictStr,
2727
)
28+
from pydantic_core import to_jsonable_python
2829
from typing_extensions import Self
2930

3031

@@ -59,7 +60,8 @@ class CreateShareExportPolicyRequestRule(BaseModel):
5960
__properties: ClassVar[List[str]] = ["description", "ipAcl", "order", "readOnly", "setUuid", "superUser"]
6061

6162
model_config = ConfigDict(
62-
populate_by_name=True,
63+
validate_by_name=True,
64+
validate_by_alias=True,
6365
validate_assignment=True,
6466
protected_namespaces=(),
6567
)
@@ -70,8 +72,7 @@ def to_str(self) -> str:
7072

7173
def to_json(self) -> str:
7274
"""Returns the JSON representation of the model using alias"""
73-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
74-
return json.dumps(self.to_dict())
75+
return json.dumps(to_jsonable_python(self.to_dict()))
7576

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

services/sfs/src/stackit/sfs/models/create_share_export_policy_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, Field
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.sfs.models.share_export_policy import ShareExportPolicy
@@ -34,7 +35,8 @@ class CreateShareExportPolicyResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["shareExportPolicy"]
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/sfs/src/stackit/sfs/models/create_share_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, StrictInt, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -43,7 +44,8 @@ class CreateSharePayload(BaseModel):
4344
__properties: ClassVar[List[str]] = ["exportPolicyName", "labels", "name", "spaceHardLimitGigabytes"]
4445

4546
model_config = ConfigDict(
46-
populate_by_name=True,
47+
validate_by_name=True,
48+
validate_by_alias=True,
4749
validate_assignment=True,
4850
protected_namespaces=(),
4951
)
@@ -54,8 +56,7 @@ def to_str(self) -> str:
5456

5557
def to_json(self) -> str:
5658
"""Returns the JSON representation of the model using alias"""
57-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
58-
return json.dumps(self.to_dict())
59+
return json.dumps(to_jsonable_python(self.to_dict()))
5960

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

0 commit comments

Comments
 (0)