|
| 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 |
0 commit comments