|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + SKE-API |
| 5 | +
|
| 6 | + The SKE API provides endpoints to create, update, delete clusters within STACKIT portal projects and to trigger further cluster management tasks. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 2.0 |
| 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 typing import Any, ClassVar, Dict, List, Optional, Set |
| 20 | + |
| 21 | +from pydantic import BaseModel, ConfigDict, Field, field_validator |
| 22 | +from typing_extensions import Annotated, Self |
| 23 | + |
| 24 | + |
| 25 | +class NodepoolKubernetes(BaseModel): |
| 26 | + """ |
| 27 | + NodepoolKubernetes |
| 28 | + """ # noqa: E501 |
| 29 | + |
| 30 | + version: Optional[Annotated[str, Field(strict=True)]] = Field( |
| 31 | + default=None, |
| 32 | + 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.", |
| 33 | + ) |
| 34 | + __properties: ClassVar[List[str]] = ["version"] |
| 35 | + |
| 36 | + @field_validator("version") |
| 37 | + def version_validate_regular_expression(cls, value): |
| 38 | + """Validates the regular expression""" |
| 39 | + if value is None: |
| 40 | + return value |
| 41 | + |
| 42 | + if not re.match(r"^\d+\.\d+\.\d+$", value): |
| 43 | + raise ValueError(r"must validate the regular expression /^\d+\.\d+\.\d+$/") |
| 44 | + return value |
| 45 | + |
| 46 | + model_config = ConfigDict( |
| 47 | + populate_by_name=True, |
| 48 | + validate_assignment=True, |
| 49 | + protected_namespaces=(), |
| 50 | + ) |
| 51 | + |
| 52 | + def to_str(self) -> str: |
| 53 | + """Returns the string representation of the model using alias""" |
| 54 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 55 | + |
| 56 | + def to_json(self) -> str: |
| 57 | + """Returns the JSON representation of the model using alias""" |
| 58 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 59 | + return json.dumps(self.to_dict()) |
| 60 | + |
| 61 | + @classmethod |
| 62 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 63 | + """Create an instance of NodepoolKubernetes from a JSON string""" |
| 64 | + return cls.from_dict(json.loads(json_str)) |
| 65 | + |
| 66 | + def to_dict(self) -> Dict[str, Any]: |
| 67 | + """Return the dictionary representation of the model using alias. |
| 68 | +
|
| 69 | + This has the following differences from calling pydantic's |
| 70 | + `self.model_dump(by_alias=True)`: |
| 71 | +
|
| 72 | + * `None` is only added to the output dict for nullable fields that |
| 73 | + were set at model initialization. Other fields with value `None` |
| 74 | + are ignored. |
| 75 | + """ |
| 76 | + excluded_fields: Set[str] = set([]) |
| 77 | + |
| 78 | + _dict = self.model_dump( |
| 79 | + by_alias=True, |
| 80 | + exclude=excluded_fields, |
| 81 | + exclude_none=True, |
| 82 | + ) |
| 83 | + return _dict |
| 84 | + |
| 85 | + @classmethod |
| 86 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 87 | + """Create an instance of NodepoolKubernetes from a dict""" |
| 88 | + if obj is None: |
| 89 | + return None |
| 90 | + |
| 91 | + if not isinstance(obj, dict): |
| 92 | + return cls.model_validate(obj) |
| 93 | + |
| 94 | + _obj = cls.model_validate({"version": obj.get("version")}) |
| 95 | + return _obj |
0 commit comments