add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from .. import types
|
||||
from ..models.logical_operator_enum import LogicalOperatorEnum
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PatchedCondition")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PatchedCondition:
|
||||
"""Serializer (read/write) for `Condition` model
|
||||
|
||||
Attributes:
|
||||
event (Union[Unset, int]):
|
||||
event_id (Union[Unset, int]):
|
||||
id (Union[Unset, int]):
|
||||
name (Union[Unset, str]):
|
||||
logical_operator (Union[Unset, LogicalOperatorEnum]): * `or` - OR
|
||||
* `and` - AND
|
||||
is_implicit (Union[Unset, bool]): can store a combination of conditions as a single condition
|
||||
"""
|
||||
|
||||
event: Union[Unset, int] = UNSET
|
||||
event_id: Union[Unset, int] = UNSET
|
||||
id: Union[Unset, int] = UNSET
|
||||
name: Union[Unset, str] = UNSET
|
||||
logical_operator: Union[Unset, LogicalOperatorEnum] = UNSET
|
||||
is_implicit: Union[Unset, bool] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
event = self.event
|
||||
|
||||
event_id = self.event_id
|
||||
|
||||
id = self.id
|
||||
|
||||
name = self.name
|
||||
|
||||
logical_operator: Union[Unset, str] = UNSET
|
||||
if not isinstance(self.logical_operator, Unset):
|
||||
logical_operator = self.logical_operator.value
|
||||
|
||||
is_implicit = self.is_implicit
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update({})
|
||||
if event is not UNSET:
|
||||
field_dict["event"] = event
|
||||
if event_id is not UNSET:
|
||||
field_dict["event_id"] = event_id
|
||||
if id is not UNSET:
|
||||
field_dict["id"] = id
|
||||
if name is not UNSET:
|
||||
field_dict["name"] = name
|
||||
if logical_operator is not UNSET:
|
||||
field_dict["logical_operator"] = logical_operator
|
||||
if is_implicit is not UNSET:
|
||||
field_dict["is_implicit"] = is_implicit
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
if not isinstance(self.event, Unset):
|
||||
files.append(("event", (None, str(self.event).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.event_id, Unset):
|
||||
files.append(("event_id", (None, str(self.event_id).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.id, Unset):
|
||||
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.name, Unset):
|
||||
files.append(("name", (None, str(self.name).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.logical_operator, Unset):
|
||||
files.append(("logical_operator", (None, str(self.logical_operator.value).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.is_implicit, Unset):
|
||||
files.append(("is_implicit", (None, str(self.is_implicit).encode(), "text/plain")))
|
||||
|
||||
for prop_name, prop in self.additional_properties.items():
|
||||
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
||||
|
||||
return files
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
event = d.pop("event", UNSET)
|
||||
|
||||
event_id = d.pop("event_id", UNSET)
|
||||
|
||||
id = d.pop("id", UNSET)
|
||||
|
||||
name = d.pop("name", UNSET)
|
||||
|
||||
_logical_operator = d.pop("logical_operator", UNSET)
|
||||
logical_operator: Union[Unset, LogicalOperatorEnum]
|
||||
if isinstance(_logical_operator, Unset):
|
||||
logical_operator = UNSET
|
||||
else:
|
||||
logical_operator = LogicalOperatorEnum(_logical_operator)
|
||||
|
||||
is_implicit = d.pop("is_implicit", UNSET)
|
||||
|
||||
patched_condition = cls(
|
||||
event=event,
|
||||
event_id=event_id,
|
||||
id=id,
|
||||
name=name,
|
||||
logical_operator=logical_operator,
|
||||
is_implicit=is_implicit,
|
||||
)
|
||||
|
||||
patched_condition.additional_properties = d
|
||||
return patched_condition
|
||||
|
||||
@property
|
||||
def additional_keys(self) -> list[str]:
|
||||
return list(self.additional_properties.keys())
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
return self.additional_properties[key]
|
||||
|
||||
def __setitem__(self, key: str, value: Any) -> None:
|
||||
self.additional_properties[key] = value
|
||||
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self.additional_properties[key]
|
||||
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self.additional_properties
|
||||
Reference in New Issue
Block a user