Skip to content

Commit f984705

Browse files
Generate iaas
1 parent e65894b commit f984705

File tree

8 files changed

+231
-26
lines changed

8 files changed

+231
-26
lines changed

services/iaas/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"]

services/iaas/stackit/iaas/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
# import models into sdk package
3737
from stackit.iaas.models.add_volume_to_server_payload import AddVolumeToServerPayload
38+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
3839
from stackit.iaas.models.area import Area
3940
from stackit.iaas.models.area_config import AreaConfig
4041
from stackit.iaas.models.area_prefix_config_ipv4 import AreaPrefixConfigIPv4

services/iaas/stackit/iaas/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# import models into model package
1818
from stackit.iaas.models.add_volume_to_server_payload import AddVolumeToServerPayload
19+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
1920
from stackit.iaas.models.area import Area
2021
from stackit.iaas.models.area_config import AreaConfig
2122
from stackit.iaas.models.area_prefix_config_ipv4 import AreaPrefixConfigIPv4
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: 1beta1
9+
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())

services/iaas/stackit/iaas/models/create_nic_payload.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
)
3030
from typing_extensions import Annotated, Self
3131

32+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
33+
3234

3335
class CreateNICPayload(BaseModel):
3436
"""
3537
Object that represents a network interface.
3638
"""
3739

38-
allowed_addresses: Optional[List[StrictStr]] = Field(
40+
allowed_addresses: Optional[List[AllowedAddressesInner]] = Field(
3941
default=None, description="A list of IPs or CIDR notations.", alias="allowedAddresses"
4042
)
4143
device: Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]] = Field(
@@ -226,6 +228,13 @@ def to_dict(self) -> Dict[str, Any]:
226228
exclude=excluded_fields,
227229
exclude_none=True,
228230
)
231+
# override the default output from pydantic by calling `to_dict()` of each item in allowed_addresses (list)
232+
_items = []
233+
if self.allowed_addresses:
234+
for _item in self.allowed_addresses:
235+
if _item:
236+
_items.append(_item.to_dict())
237+
_dict["allowedAddresses"] = _items
229238
return _dict
230239

231240
@classmethod
@@ -239,7 +248,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
239248

240249
_obj = cls.model_validate(
241250
{
242-
"allowedAddresses": obj.get("allowedAddresses"),
251+
"allowedAddresses": (
252+
[AllowedAddressesInner.from_dict(_item) for _item in obj["allowedAddresses"]]
253+
if obj.get("allowedAddresses") is not None
254+
else None
255+
),
243256
"device": obj.get("device"),
244257
"id": obj.get("id"),
245258
"ipv4": obj.get("ipv4"),

services/iaas/stackit/iaas/models/nic.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
)
3030
from typing_extensions import Annotated, Self
3131

32+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
33+
3234

3335
class NIC(BaseModel):
3436
"""
3537
Object that represents a network interface.
3638
"""
3739

38-
allowed_addresses: Optional[List[StrictStr]] = Field(
40+
allowed_addresses: Optional[List[AllowedAddressesInner]] = Field(
3941
default=None, description="A list of IPs or CIDR notations.", alias="allowedAddresses"
4042
)
4143
device: Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]] = Field(
@@ -226,6 +228,13 @@ def to_dict(self) -> Dict[str, Any]:
226228
exclude=excluded_fields,
227229
exclude_none=True,
228230
)
231+
# override the default output from pydantic by calling `to_dict()` of each item in allowed_addresses (list)
232+
_items = []
233+
if self.allowed_addresses:
234+
for _item in self.allowed_addresses:
235+
if _item:
236+
_items.append(_item.to_dict())
237+
_dict["allowedAddresses"] = _items
229238
return _dict
230239

231240
@classmethod
@@ -239,7 +248,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
239248

240249
_obj = cls.model_validate(
241250
{
242-
"allowedAddresses": obj.get("allowedAddresses"),
251+
"allowedAddresses": (
252+
[AllowedAddressesInner.from_dict(_item) for _item in obj["allowedAddresses"]]
253+
if obj.get("allowedAddresses") is not None
254+
else None
255+
),
243256
"device": obj.get("device"),
244257
"id": obj.get("id"),
245258
"ipv4": obj.get("ipv4"),

services/iaas/stackit/iaas/models/server_network.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@
1919
import re
2020
from typing import Any, ClassVar, Dict, List, Optional, Set
2121

22-
from pydantic import (
23-
BaseModel,
24-
ConfigDict,
25-
Field,
26-
StrictBool,
27-
StrictStr,
28-
field_validator,
29-
)
22+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
3023
from typing_extensions import Annotated, Self
3124

25+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
26+
3227

3328
class ServerNetwork(BaseModel):
3429
"""
3530
Describes the object that matches servers to its networks.
3631
"""
3732

38-
allowed_addresses: Optional[List[StrictStr]] = Field(
33+
allowed_addresses: Optional[List[AllowedAddressesInner]] = Field(
3934
default=None, description="A list of IPs or CIDR notations.", alias="allowedAddresses"
4035
)
4136
ipv4: Optional[Annotated[str, Field(strict=True)]] = Field(
@@ -191,6 +186,13 @@ def to_dict(self) -> Dict[str, Any]:
191186
exclude=excluded_fields,
192187
exclude_none=True,
193188
)
189+
# override the default output from pydantic by calling `to_dict()` of each item in allowed_addresses (list)
190+
_items = []
191+
if self.allowed_addresses:
192+
for _item in self.allowed_addresses:
193+
if _item:
194+
_items.append(_item.to_dict())
195+
_dict["allowedAddresses"] = _items
194196
return _dict
195197

196198
@classmethod
@@ -204,7 +206,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
204206

205207
_obj = cls.model_validate(
206208
{
207-
"allowedAddresses": obj.get("allowedAddresses"),
209+
"allowedAddresses": (
210+
[AllowedAddressesInner.from_dict(_item) for _item in obj["allowedAddresses"]]
211+
if obj.get("allowedAddresses") is not None
212+
else None
213+
),
208214
"ipv4": obj.get("ipv4"),
209215
"ipv6": obj.get("ipv6"),
210216
"mac": obj.get("mac"),

services/iaas/stackit/iaas/models/update_nic_payload.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,18 @@
1919
import re
2020
from typing import Any, ClassVar, Dict, List, Optional, Set
2121

22-
from pydantic import (
23-
BaseModel,
24-
ConfigDict,
25-
Field,
26-
StrictBool,
27-
StrictStr,
28-
field_validator,
29-
)
22+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
3023
from typing_extensions import Annotated, Self
3124

25+
from stackit.iaas.models.allowed_addresses_inner import AllowedAddressesInner
26+
3227

3328
class UpdateNICPayload(BaseModel):
3429
"""
3530
Object that represents a network interface update.
3631
"""
3732

38-
allowed_addresses: Optional[List[StrictStr]] = Field(
33+
allowed_addresses: Optional[List[AllowedAddressesInner]] = Field(
3934
default=None, description="A list of IPs or CIDR notations.", alias="allowedAddresses"
4035
)
4136
labels: Optional[Dict[str, Any]] = Field(
@@ -101,6 +96,13 @@ def to_dict(self) -> Dict[str, Any]:
10196
exclude=excluded_fields,
10297
exclude_none=True,
10398
)
99+
# override the default output from pydantic by calling `to_dict()` of each item in allowed_addresses (list)
100+
_items = []
101+
if self.allowed_addresses:
102+
for _item in self.allowed_addresses:
103+
if _item:
104+
_items.append(_item.to_dict())
105+
_dict["allowedAddresses"] = _items
104106
return _dict
105107

106108
@classmethod
@@ -114,7 +116,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
114116

115117
_obj = cls.model_validate(
116118
{
117-
"allowedAddresses": obj.get("allowedAddresses"),
119+
"allowedAddresses": (
120+
[AllowedAddressesInner.from_dict(_item) for _item in obj["allowedAddresses"]]
121+
if obj.get("allowedAddresses") is not None
122+
else None
123+
),
118124
"labels": obj.get("labels"),
119125
"name": obj.get("name"),
120126
"nicSecurity": obj.get("nicSecurity"),

0 commit comments

Comments
 (0)