Skip to content

Commit ee2d3f1

Browse files
Generate redis
1 parent 875e273 commit ee2d3f1

30 files changed

Lines changed: 129 additions & 104 deletions

services/redis/oas_commit

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

services/redis/src/stackit/redis/api/default_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ def download_backup(
13321332
_content_type: Optional[StrictStr] = None,
13331333
_headers: Optional[Dict[StrictStr, Any]] = None,
13341334
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
1335-
) -> bytearray:
1335+
) -> bytes:
13361336
"""download backup
13371337
13381338
@@ -1375,7 +1375,7 @@ def download_backup(
13751375
)
13761376

13771377
_response_types_map: Dict[str, Optional[str]] = {
1378-
"200": "bytearray",
1378+
"200": "bytes",
13791379
"500": "Error",
13801380
}
13811381
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
@@ -1400,7 +1400,7 @@ def download_backup_with_http_info(
14001400
_content_type: Optional[StrictStr] = None,
14011401
_headers: Optional[Dict[StrictStr, Any]] = None,
14021402
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
1403-
) -> ApiResponse[bytearray]:
1403+
) -> ApiResponse[bytes]:
14041404
"""download backup
14051405
14061406
@@ -1443,7 +1443,7 @@ def download_backup_with_http_info(
14431443
)
14441444

14451445
_response_types_map: Dict[str, Optional[str]] = {
1446-
"200": "bytearray",
1446+
"200": "bytes",
14471447
"500": "Error",
14481448
}
14491449
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
@@ -1511,7 +1511,7 @@ def download_backup_without_preload_content(
15111511
)
15121512

15131513
_response_types_map: Dict[str, Optional[str]] = {
1514-
"200": "bytearray",
1514+
"200": "bytes",
15151515
"500": "Error",
15161516
}
15171517
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)

services/redis/src/stackit/redis/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/redis/src/stackit/redis/models/backup.py

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

2930

@@ -41,7 +42,8 @@ class Backup(BaseModel):
4142
__properties: ClassVar[List[str]] = ["downloadable", "finished_at", "id", "size", "status", "triggered_at"]
4243

4344
model_config = ConfigDict(
44-
populate_by_name=True,
45+
validate_by_name=True,
46+
validate_by_alias=True,
4547
validate_assignment=True,
4648
protected_namespaces=(),
4749
)
@@ -52,8 +54,7 @@ def to_str(self) -> str:
5254

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

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

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

2324

@@ -31,7 +32,8 @@ class CreateBackupResponseItem(BaseModel):
3132
__properties: ClassVar[List[str]] = ["id", "message"]
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/redis/src/stackit/redis/models/create_instance_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.redis.models.instance_parameters import InstanceParameters
@@ -34,7 +35,8 @@ class CreateInstancePayload(BaseModel):
3435
__properties: ClassVar[List[str]] = ["instanceName", "parameters", "planId"]
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/redis/src/stackit/redis/models/create_instance_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

@@ -30,7 +31,8 @@ class CreateInstanceResponse(BaseModel):
3031
__properties: ClassVar[List[str]] = ["instanceId"]
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/redis/src/stackit/redis/models/credentials.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, StrictInt, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -36,7 +37,8 @@ class Credentials(BaseModel):
3637
__properties: ClassVar[List[str]] = ["host", "hosts", "load_balanced_host", "password", "port", "uri", "username"]
3738

3839
model_config = ConfigDict(
39-
populate_by_name=True,
40+
validate_by_name=True,
41+
validate_by_alias=True,
4042
validate_assignment=True,
4143
protected_namespaces=(),
4244
)
@@ -47,8 +49,7 @@ def to_str(self) -> str:
4749

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

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

services/redis/src/stackit/redis/models/credentials_list_item.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 CredentialsListItem(BaseModel):
3031
__properties: ClassVar[List[str]] = ["id"]
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/redis/src/stackit/redis/models/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, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.redis.models.raw_credentials import RawCredentials
@@ -34,7 +35,8 @@ class CredentialsResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["id", "raw", "uri"]
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]:

0 commit comments

Comments
 (0)