Source code for kittycad.models.error

from typing import Any, Dict, List, Type, TypeVar, Union

import attr

from ..types import UNSET, Unset

MS = TypeVar("MS", bound="Error")


[docs]@attr.s(auto_attribs=True) class Error: """Error information from a response.""" # noqa: E501 error_code: Union[Unset, str] = UNSET message: Union[Unset, str] = UNSET request_id: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
[docs] def to_dict(self) -> Dict[str, Any]: error_code = self.error_code message = self.message request_id = self.request_id field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if error_code is not UNSET: field_dict["error_code"] = error_code if message is not UNSET: field_dict["message"] = message if request_id is not UNSET: field_dict["request_id"] = request_id return field_dict
[docs] @classmethod def from_dict(cls: Type[MS], src_dict: Dict[str, Any]) -> MS: d = src_dict.copy() error_code = d.pop("error_code", UNSET) message = d.pop("message", UNSET) request_id = d.pop("request_id", UNSET) error = cls( error_code=error_code, message=message, request_id=request_id, ) error.additional_properties = d return error
@property def additional_keys(self) -> List[str]: return list(self.additional_properties.keys())
[docs] def __getitem__(self, key: str) -> Any: return self.additional_properties[key]
[docs] def __setitem__(self, key: str, value: Any) -> None: self.additional_properties[key] = value
[docs] def __delitem__(self, key: str) -> None: del self.additional_properties[key]
[docs] def __contains__(self, key: str) -> bool: return key in self.additional_properties