Skip to content

Commit d1f98a8

Browse files
Generate edge
1 parent 815ef3e commit d1f98a8

7 files changed

Lines changed: 256 additions & 5 deletions

File tree

services/edge/oas_commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dced41b14515398157ee7204ef11256b9e3fcbdc
1+
f03aa0907e74e8b2a68149937622d809c7c4aef5

services/edge/src/stackit/edge/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
"ApiKeyError",
2929
"ApiAttributeError",
3030
"ApiException",
31+
"Acl",
3132
"BadRequest",
3233
"CreateInstancePayload",
3334
"Instance",
3435
"InstanceList",
36+
"IpAllowListEntry",
3537
"Kubeconfig",
3638
"KubernetesReleaseList",
3739
"Plan",
@@ -58,12 +60,14 @@
5860
from stackit.edge.exceptions import OpenApiException as OpenApiException
5961

6062
# import models into sdk package
63+
from stackit.edge.models.acl import Acl as Acl
6164
from stackit.edge.models.bad_request import BadRequest as BadRequest
6265
from stackit.edge.models.create_instance_payload import (
6366
CreateInstancePayload as CreateInstancePayload,
6467
)
6568
from stackit.edge.models.instance import Instance as Instance
6669
from stackit.edge.models.instance_list import InstanceList as InstanceList
70+
from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry as IpAllowListEntry
6771
from stackit.edge.models.kubeconfig import Kubeconfig as Kubeconfig
6872
from stackit.edge.models.kubernetes_release_list import (
6973
KubernetesReleaseList as KubernetesReleaseList,

services/edge/src/stackit/edge/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) ->
4545
full_msg = msg
4646
if path_to_item:
4747
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
48-
super(ApiTypeError, self).__init__(full_msg)
48+
super(ApiTypeError, self).__init__(full_msg, path_to_item, valid_classes, key_type)
4949

5050

5151
class ApiValueError(OpenApiException, ValueError):
@@ -63,7 +63,7 @@ def __init__(self, msg, path_to_item=None) -> None:
6363
full_msg = msg
6464
if path_to_item:
6565
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
66-
super(ApiValueError, self).__init__(full_msg)
66+
super(ApiValueError, self).__init__(full_msg, path_to_item)
6767

6868

6969
class ApiAttributeError(OpenApiException, AttributeError):
@@ -82,7 +82,7 @@ def __init__(self, msg, path_to_item=None) -> None:
8282
full_msg = msg
8383
if path_to_item:
8484
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
85-
super(ApiAttributeError, self).__init__(full_msg)
85+
super(ApiAttributeError, self).__init__(full_msg, path_to_item)
8686

8787

8888
class ApiKeyError(OpenApiException, KeyError):
@@ -99,7 +99,7 @@ def __init__(self, msg, path_to_item=None) -> None:
9999
full_msg = msg
100100
if path_to_item:
101101
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
102-
super(ApiKeyError, self).__init__(full_msg)
102+
super(ApiKeyError, self).__init__(full_msg, path_to_item)
103103

104104

105105
class ApiException(OpenApiException):

services/edge/src/stackit/edge/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
""" # noqa: E501
1414

1515
# import models into model package
16+
from stackit.edge.models.acl import Acl
1617
from stackit.edge.models.bad_request import BadRequest
1718
from stackit.edge.models.create_instance_payload import CreateInstancePayload
1819
from stackit.edge.models.instance import Instance
1920
from stackit.edge.models.instance_list import InstanceList
21+
from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry
2022
from stackit.edge.models.kubeconfig import Kubeconfig
2123
from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList
2224
from stackit.edge.models.plan import Plan
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Edge Cloud API
5+
6+
This API provides endpoints for managing STACKIT Edge Cloud instances.
7+
8+
The version of the OpenAPI document: 1beta1
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
from typing import Any, ClassVar, Dict, List, Optional, Set
19+
20+
from pydantic import BaseModel, ConfigDict, Field
21+
from pydantic_core import to_jsonable_python
22+
from typing_extensions import Self
23+
24+
from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry
25+
26+
27+
class Acl(BaseModel):
28+
"""
29+
The ACL config for the instances API and all edgecluster proxies.
30+
""" # noqa: E501
31+
32+
ip_allow_list: Optional[List[IpAllowListEntry]] = Field(default=None, alias="ipAllowList")
33+
__properties: ClassVar[List[str]] = ["ipAllowList"]
34+
35+
model_config = ConfigDict(
36+
validate_by_name=True,
37+
validate_by_alias=True,
38+
validate_assignment=True,
39+
protected_namespaces=(),
40+
)
41+
42+
def to_str(self) -> str:
43+
"""Returns the string representation of the model using alias"""
44+
return pprint.pformat(self.model_dump(by_alias=True))
45+
46+
def to_json(self) -> str:
47+
"""Returns the JSON representation of the model using alias"""
48+
return json.dumps(to_jsonable_python(self.to_dict()))
49+
50+
@classmethod
51+
def from_json(cls, json_str: str) -> Optional[Self]:
52+
"""Create an instance of Acl from a JSON string"""
53+
return cls.from_dict(json.loads(json_str))
54+
55+
def to_dict(self) -> Dict[str, Any]:
56+
"""Return the dictionary representation of the model using alias.
57+
58+
This has the following differences from calling pydantic's
59+
`self.model_dump(by_alias=True)`:
60+
61+
* `None` is only added to the output dict for nullable fields that
62+
were set at model initialization. Other fields with value `None`
63+
are ignored.
64+
"""
65+
excluded_fields: Set[str] = set([])
66+
67+
_dict = self.model_dump(
68+
by_alias=True,
69+
exclude=excluded_fields,
70+
exclude_none=True,
71+
)
72+
# override the default output from pydantic by calling `to_dict()` of each item in ip_allow_list (list)
73+
_items = []
74+
if self.ip_allow_list:
75+
for _item_ip_allow_list in self.ip_allow_list:
76+
if _item_ip_allow_list:
77+
_items.append(_item_ip_allow_list.to_dict())
78+
_dict["ipAllowList"] = _items
79+
return _dict
80+
81+
@classmethod
82+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83+
"""Create an instance of Acl from a dict"""
84+
if obj is None:
85+
return None
86+
87+
if not isinstance(obj, dict):
88+
return cls.model_validate(obj)
89+
90+
_obj = cls.model_validate(
91+
{
92+
"ipAllowList": (
93+
[IpAllowListEntry.from_dict(_item) for _item in obj["ipAllowList"]]
94+
if obj.get("ipAllowList") is not None
95+
else None
96+
)
97+
}
98+
)
99+
return _obj

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
from pydantic_core import to_jsonable_python
2525
from typing_extensions import Annotated, Self
2626

27+
from stackit.edge.models.acl import Acl
28+
2729

2830
class Instance(BaseModel):
2931
"""
3032
Instance
3133
""" # noqa: E501
3234

35+
acl: Optional[Acl] = None
3336
created: datetime = Field(description="The date and time the creation of the instance was triggered.")
3437
description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
3538
default=None, description="A user chosen description to distinguish multiple instances."
@@ -44,6 +47,7 @@ class Instance(BaseModel):
4447
plan_id: UUID = Field(description="Service Plan configures the size of the Instance.", alias="planId")
4548
status: StrictStr = Field(description="The current status of the instance.")
4649
__properties: ClassVar[List[str]] = [
50+
"acl",
4751
"created",
4852
"description",
4953
"displayName",
@@ -110,6 +114,9 @@ def to_dict(self) -> Dict[str, Any]:
110114
exclude=excluded_fields,
111115
exclude_none=True,
112116
)
117+
# override the default output from pydantic by calling `to_dict()` of acl
118+
if self.acl:
119+
_dict["acl"] = self.acl.to_dict()
113120
return _dict
114121

115122
@classmethod
@@ -123,6 +130,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
123130

124131
_obj = cls.model_validate(
125132
{
133+
"acl": Acl.from_dict(obj["acl"]) if obj.get("acl") is not None else None,
126134
"created": obj.get("created"),
127135
"description": obj.get("description"),
128136
"displayName": obj.get("displayName"),
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Edge Cloud API
5+
6+
This API provides endpoints for managing STACKIT Edge Cloud instances.
7+
8+
The version of the OpenAPI document: 1beta1
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
import re # noqa: F401
19+
from datetime import datetime
20+
from typing import Any, ClassVar, Dict, List, Optional, Set
21+
from uuid import UUID
22+
23+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
24+
from pydantic_core import to_jsonable_python
25+
from typing_extensions import Annotated, Self
26+
27+
28+
class IpAllowListEntry(BaseModel):
29+
"""
30+
IpAllowListEntry
31+
""" # noqa: E501
32+
33+
created_at: Optional[datetime] = Field(
34+
default=None, description="ISO-8601 timestamp of when the entry was created.", alias="createdAt"
35+
)
36+
description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
37+
default=None, description="Some description of the entry."
38+
)
39+
ip_range: StrictStr = Field(description="The IP CIDR range for the ACL entry.", alias="ipRange")
40+
updated_at: Optional[datetime] = Field(
41+
default=None, description="ISO-8601 timestamp of when the entry was last updated.", alias="updatedAt"
42+
)
43+
uuid: UUID = Field(
44+
description="The unique identifier for the ipAllowListEntry entry. This value is immutable, used to identify entries for updates, and cannot be changed after creation."
45+
)
46+
__properties: ClassVar[List[str]] = ["createdAt", "description", "ipRange", "updatedAt", "uuid"]
47+
48+
@field_validator("created_at", mode="before")
49+
def created_at_change_year_zero_to_one(cls, value):
50+
"""Workaround which prevents year 0 issue"""
51+
if isinstance(value, str):
52+
# Check for year "0000" at the beginning of the string
53+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
54+
if value.startswith("0000-01-01T") and re.match(
55+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
56+
):
57+
# Workaround: Replace "0000" with "0001"
58+
return "0001" + value[4:] # Take "0001" and append the rest of the string
59+
return value
60+
61+
@field_validator("updated_at", mode="before")
62+
def updated_at_change_year_zero_to_one(cls, value):
63+
"""Workaround which prevents year 0 issue"""
64+
if isinstance(value, str):
65+
# Check for year "0000" at the beginning of the string
66+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
67+
if value.startswith("0000-01-01T") and re.match(
68+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
69+
):
70+
# Workaround: Replace "0000" with "0001"
71+
return "0001" + value[4:] # Take "0001" and append the rest of the string
72+
return value
73+
74+
model_config = ConfigDict(
75+
validate_by_name=True,
76+
validate_by_alias=True,
77+
validate_assignment=True,
78+
protected_namespaces=(),
79+
)
80+
81+
def to_str(self) -> str:
82+
"""Returns the string representation of the model using alias"""
83+
return pprint.pformat(self.model_dump(by_alias=True))
84+
85+
def to_json(self) -> str:
86+
"""Returns the JSON representation of the model using alias"""
87+
return json.dumps(to_jsonable_python(self.to_dict()))
88+
89+
@classmethod
90+
def from_json(cls, json_str: str) -> Optional[Self]:
91+
"""Create an instance of IpAllowListEntry from a JSON string"""
92+
return cls.from_dict(json.loads(json_str))
93+
94+
def to_dict(self) -> Dict[str, Any]:
95+
"""Return the dictionary representation of the model using alias.
96+
97+
This has the following differences from calling pydantic's
98+
`self.model_dump(by_alias=True)`:
99+
100+
* `None` is only added to the output dict for nullable fields that
101+
were set at model initialization. Other fields with value `None`
102+
are ignored.
103+
* OpenAPI `readOnly` fields are excluded.
104+
* OpenAPI `readOnly` fields are excluded.
105+
"""
106+
excluded_fields: Set[str] = set(
107+
[
108+
"created_at",
109+
"updated_at",
110+
]
111+
)
112+
113+
_dict = self.model_dump(
114+
by_alias=True,
115+
exclude=excluded_fields,
116+
exclude_none=True,
117+
)
118+
return _dict
119+
120+
@classmethod
121+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
122+
"""Create an instance of IpAllowListEntry from a dict"""
123+
if obj is None:
124+
return None
125+
126+
if not isinstance(obj, dict):
127+
return cls.model_validate(obj)
128+
129+
_obj = cls.model_validate(
130+
{
131+
"createdAt": obj.get("createdAt"),
132+
"description": obj.get("description"),
133+
"ipRange": obj.get("ipRange"),
134+
"updatedAt": obj.get("updatedAt"),
135+
"uuid": obj.get("uuid"),
136+
}
137+
)
138+
return _obj

0 commit comments

Comments
 (0)