|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from collections.abc import Mapping |
| 4 | +from typing import TYPE_CHECKING, Any, TypeVar |
| 5 | + |
| 6 | +from attrs import define as _attrs_define |
| 7 | +from attrs import field as _attrs_field |
| 8 | + |
| 9 | +from ..types import UNSET, Unset |
| 10 | + |
| 11 | +if TYPE_CHECKING: |
| 12 | + from ..models.v0043_openapi_error import V0043OpenapiError |
| 13 | + from ..models.v0043_openapi_meta import V0043OpenapiMeta |
| 14 | + from ..models.v0043_openapi_warning import V0043OpenapiWarning |
| 15 | + |
| 16 | + |
| 17 | +T = TypeVar("T", bound="V0043OpenapiResp") |
| 18 | + |
| 19 | + |
| 20 | +@_attrs_define |
| 21 | +class V0043OpenapiResp: |
| 22 | + """ |
| 23 | + Attributes: |
| 24 | + meta (V0043OpenapiMeta | Unset): |
| 25 | + errors (list[V0043OpenapiError] | Unset): |
| 26 | + warnings (list[V0043OpenapiWarning] | Unset): |
| 27 | + """ |
| 28 | + |
| 29 | + meta: V0043OpenapiMeta | Unset = UNSET |
| 30 | + errors: list[V0043OpenapiError] | Unset = UNSET |
| 31 | + warnings: list[V0043OpenapiWarning] | Unset = UNSET |
| 32 | + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) |
| 33 | + |
| 34 | + def to_dict(self) -> dict[str, Any]: |
| 35 | + meta: dict[str, Any] | Unset = UNSET |
| 36 | + if not isinstance(self.meta, Unset): |
| 37 | + meta = self.meta.to_dict() |
| 38 | + |
| 39 | + errors: list[dict[str, Any]] | Unset = UNSET |
| 40 | + if not isinstance(self.errors, Unset): |
| 41 | + errors = [] |
| 42 | + for componentsschemasv0_0_43_openapi_errors_item_data in self.errors: |
| 43 | + componentsschemasv0_0_43_openapi_errors_item = ( |
| 44 | + componentsschemasv0_0_43_openapi_errors_item_data.to_dict() |
| 45 | + ) |
| 46 | + errors.append(componentsschemasv0_0_43_openapi_errors_item) |
| 47 | + |
| 48 | + warnings: list[dict[str, Any]] | Unset = UNSET |
| 49 | + if not isinstance(self.warnings, Unset): |
| 50 | + warnings = [] |
| 51 | + for componentsschemasv0_0_43_openapi_warnings_item_data in self.warnings: |
| 52 | + componentsschemasv0_0_43_openapi_warnings_item = ( |
| 53 | + componentsschemasv0_0_43_openapi_warnings_item_data.to_dict() |
| 54 | + ) |
| 55 | + warnings.append(componentsschemasv0_0_43_openapi_warnings_item) |
| 56 | + |
| 57 | + field_dict: dict[str, Any] = {} |
| 58 | + field_dict.update(self.additional_properties) |
| 59 | + field_dict.update({}) |
| 60 | + if meta is not UNSET: |
| 61 | + field_dict["meta"] = meta |
| 62 | + if errors is not UNSET: |
| 63 | + field_dict["errors"] = errors |
| 64 | + if warnings is not UNSET: |
| 65 | + field_dict["warnings"] = warnings |
| 66 | + |
| 67 | + return field_dict |
| 68 | + |
| 69 | + @classmethod |
| 70 | + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: |
| 71 | + from ..models.v0043_openapi_error import V0043OpenapiError |
| 72 | + from ..models.v0043_openapi_meta import V0043OpenapiMeta |
| 73 | + from ..models.v0043_openapi_warning import V0043OpenapiWarning |
| 74 | + |
| 75 | + d = dict(src_dict) |
| 76 | + _meta = d.pop("meta", UNSET) |
| 77 | + meta: V0043OpenapiMeta | Unset |
| 78 | + if isinstance(_meta, Unset): |
| 79 | + meta = UNSET |
| 80 | + else: |
| 81 | + meta = V0043OpenapiMeta.from_dict(_meta) |
| 82 | + |
| 83 | + _errors = d.pop("errors", UNSET) |
| 84 | + errors: list[V0043OpenapiError] | Unset = UNSET |
| 85 | + if _errors is not UNSET: |
| 86 | + errors = [] |
| 87 | + for componentsschemasv0_0_43_openapi_errors_item_data in _errors: |
| 88 | + componentsschemasv0_0_43_openapi_errors_item = V0043OpenapiError.from_dict( |
| 89 | + componentsschemasv0_0_43_openapi_errors_item_data |
| 90 | + ) |
| 91 | + |
| 92 | + errors.append(componentsschemasv0_0_43_openapi_errors_item) |
| 93 | + |
| 94 | + _warnings = d.pop("warnings", UNSET) |
| 95 | + warnings: list[V0043OpenapiWarning] | Unset = UNSET |
| 96 | + if _warnings is not UNSET: |
| 97 | + warnings = [] |
| 98 | + for componentsschemasv0_0_43_openapi_warnings_item_data in _warnings: |
| 99 | + componentsschemasv0_0_43_openapi_warnings_item = V0043OpenapiWarning.from_dict( |
| 100 | + componentsschemasv0_0_43_openapi_warnings_item_data |
| 101 | + ) |
| 102 | + |
| 103 | + warnings.append(componentsschemasv0_0_43_openapi_warnings_item) |
| 104 | + |
| 105 | + v0043_openapi_resp = cls( |
| 106 | + meta=meta, |
| 107 | + errors=errors, |
| 108 | + warnings=warnings, |
| 109 | + ) |
| 110 | + |
| 111 | + v0043_openapi_resp.additional_properties = d |
| 112 | + return v0043_openapi_resp |
| 113 | + |
| 114 | + @property |
| 115 | + def additional_keys(self) -> list[str]: |
| 116 | + return list(self.additional_properties.keys()) |
| 117 | + |
| 118 | + def __getitem__(self, key: str) -> Any: |
| 119 | + return self.additional_properties[key] |
| 120 | + |
| 121 | + def __setitem__(self, key: str, value: Any) -> None: |
| 122 | + self.additional_properties[key] = value |
| 123 | + |
| 124 | + def __delitem__(self, key: str) -> None: |
| 125 | + del self.additional_properties[key] |
| 126 | + |
| 127 | + def __contains__(self, key: str) -> bool: |
| 128 | + return key in self.additional_properties |
0 commit comments