Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/edge/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dced41b14515398157ee7204ef11256b9e3fcbdc
8fcf792fbef3e409c27d322e4793a04f005200fb
4 changes: 4 additions & 0 deletions services/edge/src/stackit/edge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
"ApiKeyError",
"ApiAttributeError",
"ApiException",
"Acl",
"BadRequest",
"CreateInstancePayload",
"Instance",
"InstanceList",
"IpAllowListEntry",
"Kubeconfig",
"KubernetesReleaseList",
"Plan",
Expand All @@ -58,12 +60,14 @@
from stackit.edge.exceptions import OpenApiException as OpenApiException

# import models into sdk package
from stackit.edge.models.acl import Acl as Acl
from stackit.edge.models.bad_request import BadRequest as BadRequest
from stackit.edge.models.create_instance_payload import (
CreateInstancePayload as CreateInstancePayload,
)
from stackit.edge.models.instance import Instance as Instance
from stackit.edge.models.instance_list import InstanceList as InstanceList
from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry as IpAllowListEntry
from stackit.edge.models.kubeconfig import Kubeconfig as Kubeconfig
from stackit.edge.models.kubernetes_release_list import (
KubernetesReleaseList as KubernetesReleaseList,
Expand Down
8 changes: 4 additions & 4 deletions services/edge/src/stackit/edge/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) ->
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiTypeError, self).__init__(full_msg)
super(ApiTypeError, self).__init__(full_msg, path_to_item, valid_classes, key_type)


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


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


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


class ApiException(OpenApiException):
Expand Down
2 changes: 2 additions & 0 deletions services/edge/src/stackit/edge/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
""" # noqa: E501

# import models into model package
from stackit.edge.models.acl import Acl
from stackit.edge.models.bad_request import BadRequest
from stackit.edge.models.create_instance_payload import CreateInstancePayload
from stackit.edge.models.instance import Instance
from stackit.edge.models.instance_list import InstanceList
from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry
from stackit.edge.models.kubeconfig import Kubeconfig
from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList
from stackit.edge.models.plan import Plan
Expand Down
99 changes: 99 additions & 0 deletions services/edge/src/stackit/edge/models/acl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# coding: utf-8

"""
STACKIT Edge Cloud API

This API provides endpoints for managing STACKIT Edge Cloud instances.

The version of the OpenAPI document: 1beta1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field
from pydantic_core import to_jsonable_python
from typing_extensions import Self

from stackit.edge.models.ip_allow_list_entry import IpAllowListEntry


class Acl(BaseModel):
"""
The ACL config for the instances API.
""" # noqa: E501

ip_allow_list: Optional[List[IpAllowListEntry]] = Field(default=None, alias="ipAllowList")
__properties: ClassVar[List[str]] = ["ipAllowList"]

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of Acl from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of each item in ip_allow_list (list)
_items = []
if self.ip_allow_list:
for _item_ip_allow_list in self.ip_allow_list:
if _item_ip_allow_list:
_items.append(_item_ip_allow_list.to_dict())
_dict["ipAllowList"] = _items
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of Acl from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate(
{
"ipAllowList": (
[IpAllowListEntry.from_dict(_item) for _item in obj["ipAllowList"]]
if obj.get("ipAllowList") is not None
else None
)
}
)
return _obj
8 changes: 8 additions & 0 deletions services/edge/src/stackit/edge/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
from pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self

from stackit.edge.models.acl import Acl


class Instance(BaseModel):
"""
Instance
""" # noqa: E501

acl: Optional[Acl] = None
created: datetime = Field(description="The date and time the creation of the instance was triggered.")
description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
default=None, description="A user chosen description to distinguish multiple instances."
Expand All @@ -44,6 +47,7 @@ class Instance(BaseModel):
plan_id: UUID = Field(description="Service Plan configures the size of the Instance.", alias="planId")
status: StrictStr = Field(description="The current status of the instance.")
__properties: ClassVar[List[str]] = [
"acl",
"created",
"description",
"displayName",
Expand Down Expand Up @@ -110,6 +114,9 @@ def to_dict(self) -> Dict[str, Any]:
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of acl
if self.acl:
_dict["acl"] = self.acl.to_dict()
return _dict

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

_obj = cls.model_validate(
{
"acl": Acl.from_dict(obj["acl"]) if obj.get("acl") is not None else None,
"created": obj.get("created"),
"description": obj.get("description"),
"displayName": obj.get("displayName"),
Expand Down
138 changes: 138 additions & 0 deletions services/edge/src/stackit/edge/models/ip_allow_list_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# coding: utf-8

"""
STACKIT Edge Cloud API

This API provides endpoints for managing STACKIT Edge Cloud instances.

The version of the OpenAPI document: 1beta1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
import re # noqa: F401
from datetime import datetime
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self


class IpAllowListEntry(BaseModel):
"""
IpAllowListEntry
""" # noqa: E501

created_at: Optional[datetime] = Field(
default=None, description="ISO-8601 timestamp of when the entry was created.", alias="createdAt"
)
description: Optional[Annotated[str, Field(strict=True, max_length=256)]] = Field(
default=None, description="Some description of the entry."
)
ip_range: StrictStr = Field(description="The IP CIDR range for the ACL entry.", alias="ipRange")
updated_at: Optional[datetime] = Field(
default=None, description="ISO-8601 timestamp of when the entry was last updated.", alias="updatedAt"
)
uuid: UUID = Field(
description="The unique identifier for the ipAllowListEntry entry. This value is immutable, used to identify entries for updates, and cannot be changed after creation."
)
__properties: ClassVar[List[str]] = ["createdAt", "description", "ipRange", "updatedAt", "uuid"]

@field_validator("created_at", mode="before")
def created_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

@field_validator("updated_at", mode="before")
def updated_at_change_year_zero_to_one(cls, value):
"""Workaround which prevents year 0 issue"""
if isinstance(value, str):
# Check for year "0000" at the beginning of the string
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
if value.startswith("0000-01-01T") and re.match(
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
):
# Workaround: Replace "0000" with "0001"
return "0001" + value[4:] # Take "0001" and append the rest of the string
return value

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of IpAllowListEntry from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
"""
excluded_fields: Set[str] = set(
[
"created_at",
"updated_at",
]
)

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of IpAllowListEntry from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate(
{
"createdAt": obj.get("createdAt"),
"description": obj.get("description"),
"ipRange": obj.get("ipRange"),
"updatedAt": obj.get("updatedAt"),
"uuid": obj.get("uuid"),
}
)
return _obj
Loading