Skip to content

Commit 6114996

Browse files
Generate dns
1 parent 875e273 commit 6114996

38 files changed

Lines changed: 160 additions & 126 deletions

services/dns/oas_commit

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

services/dns/src/stackit/dns/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/dns/src/stackit/dns/models/clone_zone_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, StrictBool
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -45,7 +46,8 @@ class CloneZonePayload(BaseModel):
4546
__properties: ClassVar[List[str]] = ["adjustRecords", "description", "dnsName", "name"]
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/dns/src/stackit/dns/models/create_label_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
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -32,7 +33,8 @@ class CreateLabelPayload(BaseModel):
3233
__properties: ClassVar[List[str]] = ["key", "value"]
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/dns/src/stackit/dns/models/create_label_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
from stackit.dns.models.label import Label
@@ -34,7 +35,8 @@ class CreateLabelResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["label", "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/dns/src/stackit/dns/models/create_record_set_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, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425
from stackit.dns.models.record_payload import RecordPayload
@@ -80,7 +81,8 @@ def type_validate_enum(cls, value):
8081
return value
8182

8283
model_config = ConfigDict(
83-
populate_by_name=True,
84+
validate_by_name=True,
85+
validate_by_alias=True,
8486
validate_assignment=True,
8587
protected_namespaces=(),
8688
)
@@ -91,8 +93,7 @@ def to_str(self) -> str:
9193

9294
def to_json(self) -> str:
9395
"""Returns the JSON representation of the model using alias"""
94-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
95-
return json.dumps(self.to_dict())
96+
return json.dumps(to_jsonable_python(self.to_dict()))
9697

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

services/dns/src/stackit/dns/models/create_zone_payload.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
StrictStr,
2727
field_validator,
2828
)
29+
from pydantic_core import to_jsonable_python
2930
from typing_extensions import Annotated, Self
3031

3132
from stackit.dns.models.zone_extensions import ZoneExtensions
@@ -98,7 +99,8 @@ def type_validate_enum(cls, value):
9899
return value
99100

100101
model_config = ConfigDict(
101-
populate_by_name=True,
102+
validate_by_name=True,
103+
validate_by_alias=True,
102104
validate_assignment=True,
103105
protected_namespaces=(),
104106
)
@@ -109,8 +111,7 @@ def to_str(self) -> str:
109111

110112
def to_json(self) -> str:
111113
"""Returns the JSON representation of the model using alias"""
112-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
113-
return json.dumps(self.to_dict())
114+
return json.dumps(to_jsonable_python(self.to_dict()))
114115

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

services/dns/src/stackit/dns/models/delete_label_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
from stackit.dns.models.label import Label
@@ -34,7 +35,8 @@ class DeleteLabelResponse(BaseModel):
3435
__properties: ClassVar[List[str]] = ["label", "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/dns/src/stackit/dns/models/domain_extensions.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
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Self
2324

2425
from stackit.dns.models.domain_observability_extension import (
@@ -37,7 +38,8 @@ class DomainExtensions(BaseModel):
3738
__properties: ClassVar[List[str]] = ["observabilityExtension"]
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/dns/src/stackit/dns/models/domain_observability_extension.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

@@ -32,7 +33,8 @@ class DomainObservabilityExtension(BaseModel):
3233
__properties: ClassVar[List[str]] = ["observabilityInstanceId", "state"]
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]:

0 commit comments

Comments
 (0)