Skip to content

Commit 8f3b58a

Browse files
Generate serviceenablement
1 parent 875e273 commit 8f3b58a

11 files changed

Lines changed: 61 additions & 45 deletions

File tree

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

services/serviceenablement/src/stackit/serviceenablement/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/serviceenablement/src/stackit/serviceenablement/models/action_error.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, field_validator
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -42,7 +43,8 @@ def action_validate_enum(cls, value):
4243
return value
4344

4445
model_config = ConfigDict(
45-
populate_by_name=True,
46+
validate_by_name=True,
47+
validate_by_alias=True,
4648
validate_assignment=True,
4749
protected_namespaces=(),
4850
)
@@ -53,8 +55,7 @@ def to_str(self) -> str:
5355

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

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

services/serviceenablement/src/stackit/serviceenablement/models/check_service.py

Lines changed: 7 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

@@ -50,12 +51,16 @@ def service_id_validate_regular_expression(cls, value):
5051
if value is None:
5152
return value
5253

54+
if not isinstance(value, str):
55+
value = str(value)
56+
5357
if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value):
5458
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/")
5559
return value
5660

5761
model_config = ConfigDict(
58-
populate_by_name=True,
62+
validate_by_name=True,
63+
validate_by_alias=True,
5964
validate_assignment=True,
6065
protected_namespaces=(),
6166
)
@@ -66,8 +71,7 @@ def to_str(self) -> str:
6671

6772
def to_json(self) -> str:
6873
"""Returns the JSON representation of the model using alias"""
69-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
70-
return json.dumps(self.to_dict())
74+
return json.dumps(to_jsonable_python(self.to_dict()))
7175

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

services/serviceenablement/src/stackit/serviceenablement/models/cloud_service.py

Lines changed: 7 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.serviceenablement.models.dependencies import Dependencies
@@ -53,12 +54,16 @@ def service_id_validate_regular_expression(cls, value):
5354
if value is None:
5455
return value
5556

57+
if not isinstance(value, str):
58+
value = str(value)
59+
5660
if not re.match(r"^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$", value):
5761
raise ValueError(r"must validate the regular expression /^[a-zA-Z0-9][a-zA-Z0-9._-]{1,254}$/")
5862
return value
5963

6064
model_config = ConfigDict(
61-
populate_by_name=True,
65+
validate_by_name=True,
66+
validate_by_alias=True,
6267
validate_assignment=True,
6368
protected_namespaces=(),
6469
)
@@ -69,8 +74,7 @@ def to_str(self) -> str:
6974

7075
def to_json(self) -> str:
7176
"""Returns the JSON representation of the model using alias"""
72-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
73-
return json.dumps(self.to_dict())
77+
return json.dumps(to_jsonable_python(self.to_dict()))
7478

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

services/serviceenablement/src/stackit/serviceenablement/models/dependencies.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

@@ -37,7 +38,8 @@ class Dependencies(BaseModel):
3738
__properties: ClassVar[List[str]] = ["hard", "soft"]
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/serviceenablement/src/stackit/serviceenablement/models/error_response.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, StrictInt, StrictStr, field_validator
23+
from pydantic_core import to_jsonable_python
2324
from typing_extensions import Self
2425

2526

@@ -49,7 +50,8 @@ def timestamp_change_year_zero_to_one(cls, value):
4950
return value
5051

5152
model_config = ConfigDict(
52-
populate_by_name=True,
53+
validate_by_name=True,
54+
validate_by_alias=True,
5355
validate_assignment=True,
5456
protected_namespaces=(),
5557
)
@@ -60,8 +62,7 @@ def to_str(self) -> str:
6062

6163
def to_json(self) -> str:
6264
"""Returns the JSON representation of the model using alias"""
63-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
64-
return json.dumps(self.to_dict())
65+
return json.dumps(to_jsonable_python(self.to_dict()))
6566

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

services/serviceenablement/src/stackit/serviceenablement/models/list_service_status_regional200_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.serviceenablement.models.service_status import ServiceStatus
@@ -33,7 +34,8 @@ class ListServiceStatusRegional200Response(BaseModel):
3334
__properties: ClassVar[List[str]] = ["items", "nextCursor"]
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]:

services/serviceenablement/src/stackit/serviceenablement/models/parameters.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.serviceenablement.models.parameters_general import ParametersGeneral
@@ -33,7 +34,8 @@ class Parameters(BaseModel):
3334
__properties: ClassVar[List[str]] = ["general"]
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]:

services/serviceenablement/src/stackit/serviceenablement/models/parameters_general.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, field_validator
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -42,7 +43,8 @@ def project_scope_validate_enum(cls, value):
4243
return value
4344

4445
model_config = ConfigDict(
45-
populate_by_name=True,
46+
validate_by_name=True,
47+
validate_by_alias=True,
4648
validate_assignment=True,
4749
protected_namespaces=(),
4850
)
@@ -53,8 +55,7 @@ def to_str(self) -> str:
5355

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

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

0 commit comments

Comments
 (0)