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
4 changes: 4 additions & 0 deletions services/ske/src/stackit/ske/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"MaintenanceAutoUpdate",
"Network",
"Nodepool",
"NodepoolKubernetes",
"Observability",
"ProviderOptions",
"RuntimeError",
Expand Down Expand Up @@ -124,6 +125,9 @@
)
from stackit.ske.models.network import Network as Network
from stackit.ske.models.nodepool import Nodepool as Nodepool
from stackit.ske.models.nodepool_kubernetes import (
NodepoolKubernetes as NodepoolKubernetes,
)
from stackit.ske.models.observability import Observability as Observability
from stackit.ske.models.provider_options import ProviderOptions as ProviderOptions
from stackit.ske.models.runtime_error import RuntimeError as RuntimeError
Expand Down
1 change: 1 addition & 0 deletions services/ske/src/stackit/ske/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from stackit.ske.models.maintenance_auto_update import MaintenanceAutoUpdate
from stackit.ske.models.network import Network
from stackit.ske.models.nodepool import Nodepool
from stackit.ske.models.nodepool_kubernetes import NodepoolKubernetes
from stackit.ske.models.observability import Observability
from stackit.ske.models.provider_options import ProviderOptions
from stackit.ske.models.runtime_error import RuntimeError
Expand Down
9 changes: 9 additions & 0 deletions services/ske/src/stackit/ske/models/nodepool.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from stackit.ske.models.cri import CRI
from stackit.ske.models.machine import Machine
from stackit.ske.models.nodepool_kubernetes import NodepoolKubernetes
from stackit.ske.models.taint import Taint
from stackit.ske.models.volume import Volume

Expand All @@ -36,6 +37,7 @@ class Nodepool(BaseModel):
)
availability_zones: List[StrictStr] = Field(alias="availabilityZones")
cri: Optional[CRI] = None
kubernetes: Optional[NodepoolKubernetes] = None
labels: Optional[Dict[str, StrictStr]] = None
machine: Machine
max_surge: Optional[StrictInt] = Field(default=None, alias="maxSurge")
Expand All @@ -53,6 +55,7 @@ class Nodepool(BaseModel):
"allowSystemComponents",
"availabilityZones",
"cri",
"kubernetes",
"labels",
"machine",
"maxSurge",
Expand Down Expand Up @@ -104,6 +107,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of cri
if self.cri:
_dict["cri"] = self.cri.to_dict()
# override the default output from pydantic by calling `to_dict()` of kubernetes
if self.kubernetes:
_dict["kubernetes"] = self.kubernetes.to_dict()
# override the default output from pydantic by calling `to_dict()` of machine
if self.machine:
_dict["machine"] = self.machine.to_dict()
Expand Down Expand Up @@ -133,6 +139,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"allowSystemComponents": obj.get("allowSystemComponents"),
"availabilityZones": obj.get("availabilityZones"),
"cri": CRI.from_dict(obj["cri"]) if obj.get("cri") is not None else None,
"kubernetes": (
NodepoolKubernetes.from_dict(obj["kubernetes"]) if obj.get("kubernetes") is not None else None
),
"labels": obj.get("labels"),
"machine": Machine.from_dict(obj["machine"]) if obj.get("machine") is not None else None,
"maxSurge": obj.get("maxSurge"),
Expand Down
95 changes: 95 additions & 0 deletions services/ske/src/stackit/ske/models/nodepool_kubernetes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# coding: utf-8

"""
SKE-API

The SKE API provides endpoints to create, update, delete clusters within STACKIT portal projects and to trigger further cluster management tasks.

The version of the OpenAPI document: 2.0
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 typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, field_validator
from typing_extensions import Annotated, Self


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

version: Optional[Annotated[str, Field(strict=True)]] = Field(
default=None,
description="Override the Kubernetes version for the Kubelet of this Nodepool. Version must be equal or lower than the version of the cluster. Only one minor version difference to the version of the cluster is allowed. Downgrade of existing Nodepools is prohibited.",
)
__properties: ClassVar[List[str]] = ["version"]

@field_validator("version")
def version_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if value is None:
return value

if not re.match(r"^\d+\.\d+\.\d+$", value):
raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/")
return value

model_config = ConfigDict(
populate_by_name=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"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of NodepoolKubernetes 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,
)
return _dict

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

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

_obj = cls.model_validate({"version": obj.get("version")})
return _obj