Skip to content

Commit 698eee6

Browse files
Generate intake
1 parent 875e273 commit 698eee6

21 files changed

Lines changed: 101 additions & 75 deletions

services/intake/oas_commit

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

services/intake/src/stackit/intake/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/intake/src/stackit/intake/models/catalog_auth.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.intake.models.catalog_auth_type import CatalogAuthType
@@ -34,7 +35,8 @@ class CatalogAuth(BaseModel):
3435
__properties: ClassVar[List[str]] = ["dremio", "type"]
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/intake/src/stackit/intake/models/catalog_auth_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
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Self
2223

2324
from stackit.intake.models.catalog_auth_type import CatalogAuthType
@@ -34,7 +35,8 @@ class CatalogAuthPatch(BaseModel):
3435
__properties: ClassVar[List[str]] = ["dremio", "type"]
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/intake/src/stackit/intake/models/client_config.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 ClientConfig(BaseModel):
3132
__properties: ClassVar[List[str]] = ["java", "librdkafka"]
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/intake/src/stackit/intake/models/create_intake_payload.py

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

2222
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
23+
from pydantic_core import to_jsonable_python
2324
from typing_extensions import Annotated, Self
2425

2526
from stackit.intake.models.intake_catalog import IntakeCatalog
@@ -49,12 +50,16 @@ class CreateIntakePayload(BaseModel):
4950
@field_validator("display_name")
5051
def display_name_validate_regular_expression(cls, value):
5152
"""Validates the regular expression"""
53+
if not isinstance(value, str):
54+
value = str(value)
55+
5256
if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value):
5357
raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/")
5458
return value
5559

5660
model_config = ConfigDict(
57-
populate_by_name=True,
61+
validate_by_name=True,
62+
validate_by_alias=True,
5863
validate_assignment=True,
5964
protected_namespaces=(),
6065
)
@@ -65,8 +70,7 @@ def to_str(self) -> str:
6570

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

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

services/intake/src/stackit/intake/models/create_intake_runner_payload.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, StrictInt, StrictStr, field_validator
22+
from pydantic_core import to_jsonable_python
2223
from typing_extensions import Annotated, Self
2324

2425

@@ -54,12 +55,16 @@ class CreateIntakeRunnerPayload(BaseModel):
5455
@field_validator("display_name")
5556
def display_name_validate_regular_expression(cls, value):
5657
"""Validates the regular expression"""
58+
if not isinstance(value, str):
59+
value = str(value)
60+
5761
if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value):
5862
raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/")
5963
return value
6064

6165
model_config = ConfigDict(
62-
populate_by_name=True,
66+
validate_by_name=True,
67+
validate_by_alias=True,
6368
validate_assignment=True,
6469
protected_namespaces=(),
6570
)
@@ -70,8 +75,7 @@ def to_str(self) -> str:
7075

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

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

services/intake/src/stackit/intake/models/create_intake_user_payload.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.intake.models.user_type import UserType
@@ -48,12 +49,16 @@ class CreateIntakeUserPayload(BaseModel):
4849
@field_validator("display_name")
4950
def display_name_validate_regular_expression(cls, value):
5051
"""Validates the regular expression"""
52+
if not isinstance(value, str):
53+
value = str(value)
54+
5155
if not re.match(r"^[\p{L}\p{N} -]{1,32}$", value):
5256
raise ValueError(r"must validate the regular expression /^[\p{L}\p{N} -]{1,32}$/")
5357
return value
5458

5559
model_config = ConfigDict(
56-
populate_by_name=True,
60+
validate_by_name=True,
61+
validate_by_alias=True,
5762
validate_assignment=True,
5863
protected_namespaces=(),
5964
)
@@ -64,8 +69,7 @@ def to_str(self) -> str:
6469

6570
def to_json(self) -> str:
6671
"""Returns the JSON representation of the model using alias"""
67-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
68-
return json.dumps(self.to_dict())
72+
return json.dumps(to_jsonable_python(self.to_dict()))
6973

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

services/intake/src/stackit/intake/models/dremio_auth.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

@@ -35,7 +36,8 @@ class DremioAuth(BaseModel):
3536
__properties: ClassVar[List[str]] = ["personalAccessToken", "tokenEndpoint"]
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/intake/src/stackit/intake/models/dremio_auth_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
21+
from pydantic_core import to_jsonable_python
2122
from typing_extensions import Annotated, Self
2223

2324

@@ -35,7 +36,8 @@ class DremioAuthPatch(BaseModel):
3536
__properties: ClassVar[List[str]] = ["personalAccessToken", "tokenEndpoint"]
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]:

0 commit comments

Comments
 (0)