Skip to content
Closed
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 @@
95de5cba3201a683657cb472d5fa30aa768f19cc
98c11e0ee4834ddaaa474eccc437d234e6276a70
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 @@ -33,6 +33,7 @@
"Instance",
"InstanceList",
"Kubeconfig",
"KubernetesReleaseList",
"Plan",
"PlanList",
"Token",
Expand Down Expand Up @@ -64,6 +65,9 @@
from stackit.edge.models.instance import Instance as Instance
from stackit.edge.models.instance_list import InstanceList as InstanceList
from stackit.edge.models.kubeconfig import Kubeconfig as Kubeconfig
from stackit.edge.models.kubernetes_release_list import (
KubernetesReleaseList as KubernetesReleaseList,
)
from stackit.edge.models.plan import Plan as Plan
from stackit.edge.models.plan_list import PlanList as PlanList
from stackit.edge.models.token import Token as Token
Expand Down
235 changes: 235 additions & 0 deletions services/edge/src/stackit/edge/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from stackit.edge.models.instance import Instance
from stackit.edge.models.instance_list import InstanceList
from stackit.edge.models.kubeconfig import Kubeconfig
from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList
from stackit.edge.models.plan_list import PlanList
from stackit.edge.models.token import Token
from stackit.edge.models.update_instance_by_name_payload import (
Expand Down Expand Up @@ -2627,6 +2628,240 @@ def _get_token_by_instance_name_serialize(
_request_auth=_request_auth,
)

@validate_call
def list_compatible_kubernetes_releases(
self,
talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> KubernetesReleaseList:
"""list_compatible_kubernetes_releases


:param talos_version: The name of the Talos release. (required)
:type talos_version: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._list_compatible_kubernetes_releases_serialize(
talos_version=talos_version,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "KubernetesReleaseList",
"400": "BadRequest",
"404": None,
"500": None,
}
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
).data

@validate_call
def list_compatible_kubernetes_releases_with_http_info(
self,
talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[KubernetesReleaseList]:
"""list_compatible_kubernetes_releases


:param talos_version: The name of the Talos release. (required)
:type talos_version: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._list_compatible_kubernetes_releases_serialize(
talos_version=talos_version,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "KubernetesReleaseList",
"400": "BadRequest",
"404": None,
"500": None,
}
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
)

@validate_call
def list_compatible_kubernetes_releases_without_preload_content(
self,
talos_version: Annotated[StrictStr, Field(description="The name of the Talos release.")],
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> RESTResponseType:
"""list_compatible_kubernetes_releases


:param talos_version: The name of the Talos release. (required)
:type talos_version: str
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._list_compatible_kubernetes_releases_serialize(
talos_version=talos_version,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index,
)

_response_types_map: Dict[str, Optional[str]] = {
"200": "KubernetesReleaseList",
"400": "BadRequest",
"404": None,
"500": None,
}
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
return response_data.response

def _list_compatible_kubernetes_releases_serialize(
self,
talos_version,
_request_auth,
_content_type,
_headers,
_host_index,
) -> RequestSerialized:

_host = None

_collection_formats: Dict[str, str] = {}

_path_params: Dict[str, str] = {}
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
# process the query parameters
if talos_version is not None:

_query_params.append(("talosVersion", talos_version))

# process the header parameters
# process the form parameters
# process the body parameter

# set the HTTP header `Accept`
if "Accept" not in _header_params:
_header_params["Accept"] = self.api_client.select_header_accept(["application/json"])

# authentication setting
_auth_settings: List[str] = []

return self.api_client.param_serialize(
method="GET",
resource_path="/v1beta1/listcompatiblekubernetesreleases",
path_params=_path_params,
query_params=_query_params,
header_params=_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
auth_settings=_auth_settings,
collection_formats=_collection_formats,
_host=_host,
_request_auth=_request_auth,
)

@validate_call
def list_instances(
self,
Expand Down
32 changes: 15 additions & 17 deletions services/edge/src/stackit/edge/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ApiClient:
"date": datetime.date,
"datetime": datetime.datetime,
"decimal": decimal.Decimal,
"UUID": uuid.UUID,
"object": object,
}
_pool = None
Expand Down Expand Up @@ -265,7 +266,7 @@ def response_deserialize(
response_text = None
return_data = None
try:
if response_type == "bytearray":
if response_type in ("bytearray", "bytes"):
return_data = response_data.data
elif response_type == "file":
return_data = self.__deserialize_file(response_data)
Expand Down Expand Up @@ -326,25 +327,20 @@ def sanitize_for_serialization(self, obj):
return obj.isoformat()
elif isinstance(obj, decimal.Decimal):
return str(obj)

elif isinstance(obj, dict):
obj_dict = obj
return {key: self.sanitize_for_serialization(val) for key, val in obj.items()}

# Convert model obj to dict except
# attributes `openapi_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
obj_dict = obj.to_dict()
else:
# Convert model obj to dict except
# attributes `openapi_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): # noqa: B009
obj_dict = obj.to_dict()
else:
obj_dict = obj.__dict__

if isinstance(obj_dict, list):
# 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
return self.sanitize_for_serialization(obj_dict)
obj_dict = obj.__dict__

return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
return self.sanitize_for_serialization(obj_dict)

def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
"""Deserializes response into an object.
Expand Down Expand Up @@ -417,6 +413,8 @@ def __deserialize(self, data, klass):
return self.__deserialize_datetime(data)
elif klass is decimal.Decimal:
return decimal.Decimal(data)
elif klass is uuid.UUID:
return uuid.UUID(data)
elif issubclass(klass, Enum):
return self.__deserialize_enum(data, klass)
else:
Expand Down
1 change: 1 addition & 0 deletions services/edge/src/stackit/edge/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from stackit.edge.models.instance import Instance
from stackit.edge.models.instance_list import InstanceList
from stackit.edge.models.kubeconfig import Kubeconfig
from stackit.edge.models.kubernetes_release_list import KubernetesReleaseList
from stackit.edge.models.plan import Plan
from stackit.edge.models.plan_list import PlanList
from stackit.edge.models.token import Token
Expand Down
7 changes: 4 additions & 3 deletions services/edge/src/stackit/edge/models/bad_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import Any, ClassVar, Dict, List, Optional, Set

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


Expand All @@ -31,7 +32,8 @@ class BadRequest(BaseModel):
__properties: ClassVar[List[str]] = ["code", "message"]

model_config = ConfigDict(
populate_by_name=True,
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)
Expand All @@ -42,8 +44,7 @@ def to_str(self) -> str:

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

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from uuid import UUID

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


Expand All @@ -37,7 +38,8 @@ class CreateInstancePayload(BaseModel):
__properties: ClassVar[List[str]] = ["description", "displayName", "planId"]

model_config = ConfigDict(
populate_by_name=True,
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)
Expand All @@ -48,8 +50,7 @@ def to_str(self) -> str:

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

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
Expand Down
Loading
Loading