Skip to content

Commit 03a8002

Browse files
Generate iaasalpha
1 parent e65894b commit 03a8002

File tree

2 files changed

+167
-2
lines changed

2 files changed

+167
-2
lines changed

services/iaasalpha/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ dev = [
3737
]
3838

3939
[project.urls]
40-
Homepage = "https://github.com/stackitcloud/stackit-sdk-python-beta"
41-
Issues = "https://github.com/stackitcloud/stackit-sdk-python-beta/issues"
40+
Homepage = "https://github.com/stackitcloud/stackit-sdk-python"
41+
Issues = "https://github.com/stackitcloud/stackit-sdk-python/issues"
4242

4343
[build-system]
4444
requires = ["setuptools"]
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# coding: utf-8
2+
3+
"""
4+
IaaS-API
5+
6+
This API allows you to create and modify IaaS resources.
7+
8+
The version of the OpenAPI document: 1alpha1
9+
Contact: stackit-iaas@mail.schwarz
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501 docstring might be too long
14+
15+
from __future__ import annotations
16+
17+
import json
18+
import pprint
19+
from typing import Any, Dict, Optional, Set, Union
20+
21+
from pydantic import (
22+
BaseModel,
23+
ConfigDict,
24+
Field,
25+
ValidationError,
26+
field_validator,
27+
)
28+
from typing_extensions import Annotated, Self
29+
30+
31+
ALLOWEDADDRESSESINNER_ONE_OF_SCHEMAS = ["str"]
32+
33+
34+
class AllowedAddressesInner(BaseModel):
35+
"""
36+
AllowedAddressesInner
37+
"""
38+
39+
# data type: str
40+
oneof_schema_1_validator: Optional[Annotated[str, Field(strict=True)]] = Field(
41+
default=None, description="Object that represents an IP address."
42+
)
43+
# data type: str
44+
oneof_schema_2_validator: Optional[Annotated[str, Field(strict=True)]] = Field(
45+
default=None, description="Classless Inter-Domain Routing (CIDR)."
46+
)
47+
actual_instance: Optional[Union[str]] = None
48+
one_of_schemas: Set[str] = {"str"}
49+
50+
model_config = ConfigDict(
51+
validate_assignment=True,
52+
protected_namespaces=(),
53+
)
54+
55+
def __init__(self, *args, **kwargs) -> None:
56+
if args:
57+
if len(args) > 1:
58+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
59+
if kwargs:
60+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
61+
super().__init__(actual_instance=args[0])
62+
else:
63+
super().__init__(**kwargs)
64+
65+
@field_validator("actual_instance")
66+
def actual_instance_must_validate_oneof(cls, v):
67+
instance = AllowedAddressesInner.model_construct()
68+
error_messages = []
69+
match = 0
70+
# validate data type: str
71+
try:
72+
instance.oneof_schema_1_validator = v
73+
match += 1
74+
except (ValidationError, ValueError) as e:
75+
error_messages.append(str(e))
76+
# validate data type: str
77+
try:
78+
instance.oneof_schema_2_validator = v
79+
match += 1
80+
except (ValidationError, ValueError) as e:
81+
error_messages.append(str(e))
82+
if match > 1:
83+
# more than 1 match
84+
raise ValueError(
85+
"Multiple matches found when setting `actual_instance` in AllowedAddressesInner with oneOf schemas: str. Details: "
86+
+ ", ".join(error_messages)
87+
)
88+
elif match == 0:
89+
# no match
90+
raise ValueError(
91+
"No match found when setting `actual_instance` in AllowedAddressesInner with oneOf schemas: str. Details: "
92+
+ ", ".join(error_messages)
93+
)
94+
else:
95+
return v
96+
97+
@classmethod
98+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
99+
return cls.from_json(json.dumps(obj))
100+
101+
@classmethod
102+
def from_json(cls, json_str: str) -> Self:
103+
"""Returns the object represented by the json string"""
104+
instance = cls.model_construct()
105+
error_messages = []
106+
match = 0
107+
108+
# deserialize data into str
109+
try:
110+
# validation
111+
instance.oneof_schema_1_validator = json.loads(json_str)
112+
# assign value to actual_instance
113+
instance.actual_instance = instance.oneof_schema_1_validator
114+
match += 1
115+
except (ValidationError, ValueError) as e:
116+
error_messages.append(str(e))
117+
# deserialize data into str
118+
try:
119+
# validation
120+
instance.oneof_schema_2_validator = json.loads(json_str)
121+
# assign value to actual_instance
122+
instance.actual_instance = instance.oneof_schema_2_validator
123+
match += 1
124+
except (ValidationError, ValueError) as e:
125+
error_messages.append(str(e))
126+
127+
if match > 1:
128+
# more than 1 match
129+
raise ValueError(
130+
"Multiple matches found when deserializing the JSON string into AllowedAddressesInner with oneOf schemas: str. Details: "
131+
+ ", ".join(error_messages)
132+
)
133+
elif match == 0:
134+
# no match
135+
raise ValueError(
136+
"No match found when deserializing the JSON string into AllowedAddressesInner with oneOf schemas: str. Details: "
137+
+ ", ".join(error_messages)
138+
)
139+
else:
140+
return instance
141+
142+
def to_json(self) -> str:
143+
"""Returns the JSON representation of the actual instance"""
144+
if self.actual_instance is None:
145+
return "null"
146+
147+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
148+
return self.actual_instance.to_json()
149+
else:
150+
return json.dumps(self.actual_instance)
151+
152+
def to_dict(self) -> Optional[Union[Dict[str, Any], str]]:
153+
"""Returns the dict representation of the actual instance"""
154+
if self.actual_instance is None:
155+
return None
156+
157+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
158+
return self.actual_instance.to_dict()
159+
else:
160+
# primitive type
161+
return self.actual_instance
162+
163+
def to_str(self) -> str:
164+
"""Returns the string representation of the actual instance"""
165+
return pprint.pformat(self.model_dump())

0 commit comments

Comments
 (0)