Skip to content

Commit 61e90dd

Browse files
Generate objectstorage
1 parent 875e273 commit 61e90dd

28 files changed

Lines changed: 120 additions & 96 deletions

services/objectstorage/oas_commit

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

services/objectstorage/src/stackit/objectstorage/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/objectstorage/src/stackit/objectstorage/models/access_key.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 AccessKey(BaseModel):
3435
__properties: ClassVar[List[str]] = ["displayName", "expires", "keyId"]
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/objectstorage/src/stackit/objectstorage/models/bucket.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 Self
2829

2930

@@ -44,7 +45,8 @@ class Bucket(BaseModel):
4445
__properties: ClassVar[List[str]] = ["name", "objectLockEnabled", "region", "urlPathStyle", "urlVirtualHostedStyle"]
4546

4647
model_config = ConfigDict(
47-
populate_by_name=True,
48+
validate_by_name=True,
49+
validate_by_alias=True,
4850
validate_assignment=True,
4951
protected_namespaces=(),
5052
)
@@ -55,8 +57,7 @@ def to_str(self) -> str:
5557

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

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

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

2324

@@ -31,7 +32,8 @@ class ComplianceLockResponse(BaseModel):
3132
__properties: ClassVar[List[str]] = ["maxRetentionDays", "project"]
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]:

services/objectstorage/src/stackit/objectstorage/models/create_access_key_payload.py

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

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

2526

@@ -45,7 +46,8 @@ def expires_change_year_zero_to_one(cls, value):
4546
return value
4647

4748
model_config = ConfigDict(
48-
populate_by_name=True,
49+
validate_by_name=True,
50+
validate_by_alias=True,
4951
validate_assignment=True,
5052
protected_namespaces=(),
5153
)
@@ -56,8 +58,7 @@ def to_str(self) -> str:
5658

5759
def to_json(self) -> str:
5860
"""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())
61+
return json.dumps(to_jsonable_python(self.to_dict()))
6162

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

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

2324

@@ -37,7 +38,8 @@ class CreateAccessKeyResponse(BaseModel):
3738
__properties: ClassVar[List[str]] = ["accessKey", "displayName", "expires", "keyId", "project", "secretAccessKey"]
3839

3940
model_config = ConfigDict(
40-
populate_by_name=True,
41+
validate_by_name=True,
42+
validate_by_alias=True,
4143
validate_assignment=True,
4244
protected_namespaces=(),
4345
)
@@ -48,8 +50,7 @@ def to_str(self) -> str:
4850

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

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

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

2324

@@ -31,7 +32,8 @@ class CreateBucketResponse(BaseModel):
3132
__properties: ClassVar[List[str]] = ["bucket", "project"]
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]:

services/objectstorage/src/stackit/objectstorage/models/create_credentials_group_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

@@ -32,7 +33,8 @@ class CreateCredentialsGroupPayload(BaseModel):
3233
__properties: ClassVar[List[str]] = ["displayName"]
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/objectstorage/src/stackit/objectstorage/models/create_credentials_group_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, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.objectstorage.models.credentials_group import CredentialsGroup
@@ -33,7 +34,8 @@ class CreateCredentialsGroupResponse(BaseModel):
3334
__properties: ClassVar[List[str]] = ["credentialsGroup", "project"]
3435

3536
model_config = ConfigDict(
36-
populate_by_name=True,
37+
validate_by_name=True,
38+
validate_by_alias=True,
3739
validate_assignment=True,
3840
protected_namespaces=(),
3941
)
@@ -44,8 +46,7 @@ def to_str(self) -> str:
4446

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

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

0 commit comments

Comments
 (0)