Skip to content

Commit bd04de6

Browse files
Generate cdn
1 parent 875e273 commit bd04de6

71 files changed

Lines changed: 292 additions & 225 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/cdn/oas_commit

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

services/cdn/src/stackit/cdn/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/cdn/src/stackit/cdn/models/bucket_backend.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

@@ -32,7 +33,8 @@ class BucketBackend(BaseModel):
3233
__properties: ClassVar[List[str]] = ["bucketUrl", "region", "type"]
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/cdn/src/stackit/cdn/models/bucket_backend_create.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.cdn.models.bucket_credentials import BucketCredentials
@@ -35,7 +36,8 @@ class BucketBackendCreate(BaseModel):
3536
__properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"]
3637

3738
model_config = ConfigDict(
38-
populate_by_name=True,
39+
validate_by_name=True,
40+
validate_by_alias=True,
3941
validate_assignment=True,
4042
protected_namespaces=(),
4143
)
@@ -46,8 +48,7 @@ def to_str(self) -> str:
4648

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

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

services/cdn/src/stackit/cdn/models/bucket_backend_patch.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.cdn.models.bucket_credentials import BucketCredentials
@@ -35,7 +36,8 @@ class BucketBackendPatch(BaseModel):
3536
__properties: ClassVar[List[str]] = ["bucketUrl", "credentials", "region", "type"]
3637

3738
model_config = ConfigDict(
38-
populate_by_name=True,
39+
validate_by_name=True,
40+
validate_by_alias=True,
3941
validate_assignment=True,
4042
protected_namespaces=(),
4143
)
@@ -46,8 +48,7 @@ def to_str(self) -> str:
4648

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

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

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

2324

@@ -31,7 +32,8 @@ class BucketCredentials(BaseModel):
3132
__properties: ClassVar[List[str]] = ["accessKeyId", "secretAccessKey"]
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/cdn/src/stackit/cdn/models/config.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 Annotated, Self
2829

2930
from stackit.cdn.models.config_backend import ConfigBackend
@@ -90,7 +91,8 @@ class Config(BaseModel):
9091
]
9192

9293
model_config = ConfigDict(
93-
populate_by_name=True,
94+
validate_by_name=True,
95+
validate_by_alias=True,
9496
validate_assignment=True,
9597
protected_namespaces=(),
9698
)
@@ -101,8 +103,7 @@ def to_str(self) -> str:
101103

102104
def to_json(self) -> str:
103105
"""Returns the JSON representation of the model using alias"""
104-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
105-
return json.dumps(self.to_dict())
106+
return json.dumps(to_jsonable_python(self.to_dict()))
106107

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

services/cdn/src/stackit/cdn/models/config_patch.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 Annotated, Self
2829

2930
from stackit.cdn.models.config_patch_backend import ConfigPatchBackend
@@ -94,7 +95,8 @@ class ConfigPatch(BaseModel):
9495
]
9596

9697
model_config = ConfigDict(
97-
populate_by_name=True,
98+
validate_by_name=True,
99+
validate_by_alias=True,
98100
validate_assignment=True,
99101
protected_namespaces=(),
100102
)
@@ -105,8 +107,7 @@ def to_str(self) -> str:
105107

106108
def to_json(self) -> str:
107109
"""Returns the JSON representation of the model using alias"""
108-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
109-
return json.dumps(self.to_dict())
110+
return json.dumps(to_jsonable_python(self.to_dict()))
110111

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

services/cdn/src/stackit/cdn/models/create_distribution_payload.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 Annotated, Self
2829

2930
from stackit.cdn.models.create_distribution_payload_backend import (
@@ -104,7 +105,8 @@ class CreateDistributionPayload(BaseModel):
104105
]
105106

106107
model_config = ConfigDict(
107-
populate_by_name=True,
108+
validate_by_name=True,
109+
validate_by_alias=True,
108110
validate_assignment=True,
109111
protected_namespaces=(),
110112
)
@@ -115,8 +117,7 @@ def to_str(self) -> str:
115117

116118
def to_json(self) -> str:
117119
"""Returns the JSON representation of the model using alias"""
118-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
119-
return json.dumps(self.to_dict())
120+
return json.dumps(to_jsonable_python(self.to_dict()))
120121

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

services/cdn/src/stackit/cdn/models/create_distribution_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
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.cdn.models.distribution import Distribution
@@ -32,7 +33,8 @@ class CreateDistributionResponse(BaseModel):
3233
__properties: ClassVar[List[str]] = ["distribution"]
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)