Skip to content

Commit 263bfde

Browse files
Generate sqlserverflex
1 parent 875e273 commit 263bfde

56 files changed

Lines changed: 232 additions & 180 deletions

Some content is hidden

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

services/sqlserverflex/oas_commit

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

services/sqlserverflex/src/stackit/sqlserverflex/api_client.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ApiClient:
6767
"date": datetime.date,
6868
"datetime": datetime.datetime,
6969
"decimal": decimal.Decimal,
70+
"UUID": uuid.UUID,
7071
"object": object,
7172
}
7273
_pool = None
@@ -266,7 +267,7 @@ def response_deserialize(
266267
response_text = None
267268
return_data = None
268269
try:
269-
if response_type == "bytearray":
270+
if response_type in ("bytearray", "bytes"):
270271
return_data = response_data.data
271272
elif response_type == "file":
272273
return_data = self.__deserialize_file(response_data)
@@ -327,25 +328,20 @@ def sanitize_for_serialization(self, obj):
327328
return obj.isoformat()
328329
elif isinstance(obj, decimal.Decimal):
329330
return str(obj)
330-
331331
elif isinstance(obj, dict):
332-
obj_dict = obj
332+
return {key: self.sanitize_for_serialization(val) for key, val in obj.items()}
333+
334+
# Convert model obj to dict except
335+
# attributes `openapi_types`, `attribute_map`
336+
# and attributes which value is not None.
337+
# Convert attribute name to json key in
338+
# model definition for request.
339+
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
340+
obj_dict = obj.to_dict()
333341
else:
334-
# Convert model obj to dict except
335-
# attributes `openapi_types`, `attribute_map`
336-
# and attributes which value is not None.
337-
# Convert attribute name to json key in
338-
# model definition for request.
339-
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
340-
obj_dict = obj.to_dict()
341-
else:
342-
obj_dict = obj.__dict__
343-
344-
if isinstance(obj_dict, list):
345-
# 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
346-
return self.sanitize_for_serialization(obj_dict)
342+
obj_dict = obj.__dict__
347343

348-
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
344+
return self.sanitize_for_serialization(obj_dict)
349345

350346
def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
351347
"""Deserializes response into an object.
@@ -418,6 +414,8 @@ def __deserialize(self, data, klass):
418414
return self.__deserialize_datetime(data)
419415
elif klass is decimal.Decimal:
420416
return decimal.Decimal(data)
417+
elif klass is uuid.UUID:
418+
return uuid.UUID(data)
421419
elif issubclass(klass, Enum):
422420
return self.__deserialize_enum(data, klass)
423421
else:

services/sqlserverflex/src/stackit/sqlserverflex/models/acl.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -31,7 +32,8 @@ class ACL(BaseModel):
3132
__properties: ClassVar[List[str]] = ["items"]
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/sqlserverflex/src/stackit/sqlserverflex/models/backup.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -38,7 +39,8 @@ class Backup(BaseModel):
3839
__properties: ClassVar[List[str]] = ["endTime", "error", "id", "labels", "name", "options", "size", "startTime"]
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/sqlserverflex/src/stackit/sqlserverflex/models/backup_list_backups_response_grouped.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.sqlserverflex.models.backup import Backup
@@ -34,7 +35,8 @@ class BackupListBackupsResponseGrouped(BaseModel):
3435
__properties: ClassVar[List[str]] = ["backups", "name"]
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/sqlserverflex/src/stackit/sqlserverflex/models/create_database_payload.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.sqlserverflex.models.database_documentation_create_database_request_options import (
@@ -36,7 +37,8 @@ class CreateDatabasePayload(BaseModel):
3637
__properties: ClassVar[List[str]] = ["name", "options"]
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/sqlserverflex/src/stackit/sqlserverflex/models/create_database_response.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -31,7 +32,8 @@ class CreateDatabaseResponse(BaseModel):
3132
__properties: ClassVar[List[str]] = ["id"]
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/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_payload.py

Lines changed: 4 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
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.sqlserverflex.models.instance_documentation_acl import (
@@ -66,7 +67,8 @@ class CreateInstancePayload(BaseModel):
6667
]
6768

6869
model_config = ConfigDict(
69-
populate_by_name=True,
70+
validate_by_name=True,
71+
validate_by_alias=True,
7072
validate_assignment=True,
7173
protected_namespaces=(),
7274
)
@@ -77,8 +79,7 @@ def to_str(self) -> str:
7779

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

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

services/sqlserverflex/src/stackit/sqlserverflex/models/create_instance_response.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -31,7 +32,8 @@ class CreateInstanceResponse(BaseModel):
3132
__properties: ClassVar[List[str]] = ["id"]
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/sqlserverflex/src/stackit/sqlserverflex/models/create_user_payload.py

Lines changed: 4 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, StrictStr
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425

@@ -33,7 +34,8 @@ class CreateUserPayload(BaseModel):
3334
__properties: ClassVar[List[str]] = ["default_database", "roles", "username"]
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)