Skip to content

Commit e82aaba

Browse files
Generate serviceaccount
1 parent 875e273 commit e82aaba

30 files changed

Lines changed: 131 additions & 102 deletions

services/serviceaccount/oas_commit

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

services/serviceaccount/src/stackit/serviceaccount/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")): # noqa: B009
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/serviceaccount/src/stackit/serviceaccount/models/access_token.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
StrictStr,
2929
field_validator,
3030
)
31+
from pydantic_core import to_jsonable_python
3132
from typing_extensions import Self
3233

3334

@@ -75,7 +76,8 @@ def valid_until_change_year_zero_to_one(cls, value):
7576
return value
7677

7778
model_config = ConfigDict(
78-
populate_by_name=True,
79+
validate_by_name=True,
80+
validate_by_alias=True,
7981
validate_assignment=True,
8082
protected_namespaces=(),
8183
)
@@ -86,8 +88,7 @@ def to_str(self) -> str:
8688

8789
def to_json(self) -> str:
8890
"""Returns the JSON representation of the model using alias"""
89-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
90-
return json.dumps(self.to_dict())
91+
return json.dumps(to_jsonable_python(self.to_dict()))
9192

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

services/serviceaccount/src/stackit/serviceaccount/models/access_token_metadata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from uuid import UUID
2222

2323
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
24+
from pydantic_core import to_jsonable_python
2425
from typing_extensions import Self
2526

2627

@@ -67,7 +68,8 @@ def valid_until_change_year_zero_to_one(cls, value):
6768
return value
6869

6970
model_config = ConfigDict(
70-
populate_by_name=True,
71+
validate_by_name=True,
72+
validate_by_alias=True,
7173
validate_assignment=True,
7274
protected_namespaces=(),
7375
)
@@ -78,8 +80,7 @@ def to_str(self) -> str:
7880

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

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

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

2324
from stackit.serviceaccount.models.auth_error_error import AuthErrorError
@@ -32,7 +33,8 @@ class AuthError(BaseModel):
3233
__properties: ClassVar[List[str]] = ["error"]
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/serviceaccount/src/stackit/serviceaccount/models/auth_error_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, StrictInt, StrictStr
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324

@@ -32,7 +33,8 @@ class AuthErrorError(BaseModel):
3233
__properties: ClassVar[List[str]] = ["code", "message", "status"]
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/serviceaccount/src/stackit/serviceaccount/models/create_access_token_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
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Annotated, Self
2223

2324

@@ -32,7 +33,8 @@ class CreateAccessTokenPayload(BaseModel):
3233
__properties: ClassVar[List[str]] = ["ttlDays"]
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/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_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.serviceaccount.models.create_federated_identity_provider_payload_assertions_inner import (
@@ -38,7 +39,8 @@ class CreateFederatedIdentityProviderPayload(BaseModel):
3839
__properties: ClassVar[List[str]] = ["assertions", "issuer", "name"]
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/serviceaccount/src/stackit/serviceaccount/models/create_federated_identity_provider_payload_assertions_inner.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 CreateFederatedIdentityProviderPayloadAssertionsInner(BaseModel):
3233
__properties: ClassVar[List[str]] = ["item", "operator", "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/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.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, Field, StrictStr, field_validator
23+
from pydantic_core import to_jsonable_python
2324
from typing_extensions import Self
2425

2526

@@ -68,7 +69,8 @@ def valid_until_change_year_zero_to_one(cls, value):
6869
return value
6970

7071
model_config = ConfigDict(
71-
populate_by_name=True,
72+
validate_by_name=True,
73+
validate_by_alias=True,
7274
validate_assignment=True,
7375
protected_namespaces=(),
7476
)
@@ -79,8 +81,7 @@ def to_str(self) -> str:
7981

8082
def to_json(self) -> str:
8183
"""Returns the JSON representation of the model using alias"""
82-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
83-
return json.dumps(self.to_dict())
84+
return json.dumps(to_jsonable_python(self.to_dict()))
8485

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

0 commit comments

Comments
 (0)