Skip to content

Commit 8ecd0a6

Browse files
Generate secretsmanager
1 parent 875e273 commit 8ecd0a6

19 files changed

Lines changed: 84 additions & 69 deletions

services/secretsmanager/oas_commit

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

services/secretsmanager/src/stackit/secretsmanager/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/secretsmanager/src/stackit/secretsmanager/models/acl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from uuid import UUID
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 ACL(BaseModel):
3233
__properties: ClassVar[List[str]] = ["cidr", "id"]
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/secretsmanager/src/stackit/secretsmanager/models/bad_request.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

@@ -30,7 +31,8 @@ class BadRequest(BaseModel):
3031
__properties: ClassVar[List[str]] = ["message"]
3132

3233
model_config = ConfigDict(
33-
populate_by_name=True,
34+
validate_by_name=True,
35+
validate_by_alias=True,
3436
validate_assignment=True,
3537
protected_namespaces=(),
3638
)
@@ -41,8 +43,7 @@ def to_str(self) -> str:
4143

4244
def to_json(self) -> str:
4345
"""Returns the JSON representation of the model using alias"""
44-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45-
return json.dumps(self.to_dict())
46+
return json.dumps(to_jsonable_python(self.to_dict()))
4647

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

services/secretsmanager/src/stackit/secretsmanager/models/conflict.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

@@ -30,7 +31,8 @@ class Conflict(BaseModel):
3031
__properties: ClassVar[List[str]] = ["message"]
3132

3233
model_config = ConfigDict(
33-
populate_by_name=True,
34+
validate_by_name=True,
35+
validate_by_alias=True,
3436
validate_assignment=True,
3537
protected_namespaces=(),
3638
)
@@ -41,8 +43,7 @@ def to_str(self) -> str:
4143

4244
def to_json(self) -> str:
4345
"""Returns the JSON representation of the model using alias"""
44-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45-
return json.dumps(self.to_dict())
46+
return json.dumps(to_jsonable_python(self.to_dict()))
4647

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

services/secretsmanager/src/stackit/secretsmanager/models/create_acl_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

@@ -30,7 +31,8 @@ class CreateACLPayload(BaseModel):
3031
__properties: ClassVar[List[str]] = ["cidr"]
3132

3233
model_config = ConfigDict(
33-
populate_by_name=True,
34+
validate_by_name=True,
35+
validate_by_alias=True,
3436
validate_assignment=True,
3537
protected_namespaces=(),
3638
)
@@ -41,8 +43,7 @@ def to_str(self) -> str:
4143

4244
def to_json(self) -> str:
4345
"""Returns the JSON representation of the model using alias"""
44-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45-
return json.dumps(self.to_dict())
46+
return json.dumps(to_jsonable_python(self.to_dict()))
4647

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

services/secretsmanager/src/stackit/secretsmanager/models/create_instance_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.secretsmanager.models.kms_key_payload import KmsKeyPayload
@@ -33,7 +34,8 @@ class CreateInstancePayload(BaseModel):
3334
__properties: ClassVar[List[str]] = ["kmsKey", "name"]
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/secretsmanager/src/stackit/secretsmanager/models/create_user_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 Self
2829

2930

@@ -39,7 +40,8 @@ class CreateUserPayload(BaseModel):
3940
__properties: ClassVar[List[str]] = ["description", "write"]
4041

4142
model_config = ConfigDict(
42-
populate_by_name=True,
43+
validate_by_name=True,
44+
validate_by_alias=True,
4345
validate_assignment=True,
4446
protected_namespaces=(),
4547
)
@@ -50,8 +52,7 @@ def to_str(self) -> str:
5052

5153
def to_json(self) -> str:
5254
"""Returns the JSON representation of the model using alias"""
53-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54-
return json.dumps(self.to_dict())
55+
return json.dumps(to_jsonable_python(self.to_dict()))
5556

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

services/secretsmanager/src/stackit/secretsmanager/models/instance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from uuid import UUID
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
from stackit.secretsmanager.models.kms_key_payload import KmsKeyPayload
@@ -65,7 +66,8 @@ class Instance(BaseModel):
6566
]
6667

6768
model_config = ConfigDict(
68-
populate_by_name=True,
69+
validate_by_name=True,
70+
validate_by_alias=True,
6971
validate_assignment=True,
7072
protected_namespaces=(),
7173
)
@@ -76,8 +78,7 @@ def to_str(self) -> str:
7678

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

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

services/secretsmanager/src/stackit/secretsmanager/models/kms_key_payload.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from uuid import UUID
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

@@ -37,7 +38,8 @@ class KmsKeyPayload(BaseModel):
3738
__properties: ClassVar[List[str]] = ["keyId", "keyRingId", "keyVersion", "serviceAccountEmail"]
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]:

0 commit comments

Comments
 (0)