Skip to content

Commit 11fa60d

Browse files
Generate ske
1 parent 415d2dc commit 11fa60d

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

services/ske/src/stackit/ske/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from stackit.ske.models.argus import Argus
3838
from stackit.ske.models.availability_zone import AvailabilityZone
3939
from stackit.ske.models.cluster import Cluster
40+
from stackit.ske.models.cluster_error import ClusterError
4041
from stackit.ske.models.cluster_status import ClusterStatus
4142
from stackit.ske.models.cluster_status_state import ClusterStatusState
4243
from stackit.ske.models.create_kubeconfig_payload import CreateKubeconfigPayload

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

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from stackit.ske.models.argus import Argus
1919
from stackit.ske.models.availability_zone import AvailabilityZone
2020
from stackit.ske.models.cluster import Cluster
21+
from stackit.ske.models.cluster_error import ClusterError
2122
from stackit.ske.models.cluster_status import ClusterStatus
2223
from stackit.ske.models.cluster_status_state import ClusterStatusState
2324
from stackit.ske.models.create_kubeconfig_payload import CreateKubeconfigPayload
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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: 1.1
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501 docstring might be too long
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, StrictStr, field_validator
21+
from typing_extensions import Self
22+
23+
24+
class ClusterError(BaseModel):
25+
"""
26+
ClusterError
27+
"""
28+
29+
code: Optional[StrictStr] = None
30+
message: Optional[StrictStr] = None
31+
__properties: ClassVar[List[str]] = ["code", "message"]
32+
33+
@field_validator("code")
34+
def code_validate_enum(cls, value):
35+
"""Validates the enum"""
36+
if value is None:
37+
return value
38+
39+
if value not in set(
40+
[
41+
"SKE_OBSERVABILITY_INSTANCE_NOT_FOUND",
42+
"SKE_DNS_ZONE_NOT_FOUND",
43+
"SKE_NODE_MISCONFIGURED_PDB",
44+
"SKE_NODE_NO_VALID_HOST_FOUND",
45+
"SKE_NODE_MACHINE_TYPE_NOT_FOUND",
46+
]
47+
):
48+
raise ValueError(
49+
"must be one of enum values ('SKE_OBSERVABILITY_INSTANCE_NOT_FOUND', 'SKE_DNS_ZONE_NOT_FOUND', 'SKE_NODE_MISCONFIGURED_PDB', 'SKE_NODE_NO_VALID_HOST_FOUND', 'SKE_NODE_MACHINE_TYPE_NOT_FOUND')"
50+
)
51+
return value
52+
53+
model_config = ConfigDict(
54+
populate_by_name=True,
55+
validate_assignment=True,
56+
protected_namespaces=(),
57+
)
58+
59+
def to_str(self) -> str:
60+
"""Returns the string representation of the model using alias"""
61+
return pprint.pformat(self.model_dump(by_alias=True))
62+
63+
def to_json(self) -> str:
64+
"""Returns the JSON representation of the model using alias"""
65+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66+
return json.dumps(self.to_dict())
67+
68+
@classmethod
69+
def from_json(cls, json_str: str) -> Optional[Self]:
70+
"""Create an instance of ClusterError from a JSON string"""
71+
return cls.from_dict(json.loads(json_str))
72+
73+
def to_dict(self) -> Dict[str, Any]:
74+
"""Return the dictionary representation of the model using alias.
75+
76+
This has the following differences from calling pydantic's
77+
`self.model_dump(by_alias=True)`:
78+
79+
* `None` is only added to the output dict for nullable fields that
80+
were set at model initialization. Other fields with value `None`
81+
are ignored.
82+
"""
83+
excluded_fields: Set[str] = set([])
84+
85+
_dict = self.model_dump(
86+
by_alias=True,
87+
exclude=excluded_fields,
88+
exclude_none=True,
89+
)
90+
return _dict
91+
92+
@classmethod
93+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94+
"""Create an instance of ClusterError from a dict"""
95+
if obj is None:
96+
return None
97+
98+
if not isinstance(obj, dict):
99+
return cls.model_validate(obj)
100+
101+
_obj = cls.model_validate({"code": obj.get("code"), "message": obj.get("message")})
102+
return _obj

services/ske/src/stackit/ske/models/cluster_status.py

+15
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
2222
from typing_extensions import Self
2323

24+
from stackit.ske.models.cluster_error import ClusterError
2425
from stackit.ske.models.cluster_status_state import ClusterStatusState
2526
from stackit.ske.models.credentials_rotation_state import CredentialsRotationState
2627
from stackit.ske.models.runtime_error import RuntimeError
@@ -42,13 +43,15 @@ class ClusterStatus(BaseModel):
4243
alias="egressAddressRanges",
4344
)
4445
error: Optional[RuntimeError] = None
46+
errors: Optional[List[ClusterError]] = None
4547
hibernated: Optional[StrictBool] = None
4648
__properties: ClassVar[List[str]] = [
4749
"aggregated",
4850
"creationTime",
4951
"credentialsRotation",
5052
"egressAddressRanges",
5153
"error",
54+
"errors",
5255
"hibernated",
5356
]
5457

@@ -95,6 +98,13 @@ def to_dict(self) -> Dict[str, Any]:
9598
# override the default output from pydantic by calling `to_dict()` of error
9699
if self.error:
97100
_dict["error"] = self.error.to_dict()
101+
# override the default output from pydantic by calling `to_dict()` of each item in errors (list)
102+
_items = []
103+
if self.errors:
104+
for _item in self.errors:
105+
if _item:
106+
_items.append(_item.to_dict())
107+
_dict["errors"] = _items
98108
return _dict
99109

100110
@classmethod
@@ -119,6 +129,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
119129
),
120130
"egressAddressRanges": obj.get("egressAddressRanges"),
121131
"error": RuntimeError.from_dict(obj["error"]) if obj.get("error") is not None else None,
132+
"errors": (
133+
[ClusterError.from_dict(_item) for _item in obj["errors"]]
134+
if obj.get("errors") is not None
135+
else None
136+
),
122137
"hibernated": obj.get("hibernated"),
123138
}
124139
)

0 commit comments

Comments
 (0)