100 lines
2.8 KiB
Python
100 lines
2.8 KiB
Python
import datetime
|
|
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Union, cast
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
from dateutil.parser import isoparse
|
|
|
|
T = TypeVar("T", bound="RequestOTT")
|
|
|
|
|
|
@_attrs_define
|
|
class RequestOTT:
|
|
"""
|
|
Attributes:
|
|
application (str):
|
|
ott (Union[None, str]):
|
|
ott_expire (Union[None, datetime.datetime]):
|
|
"""
|
|
|
|
application: str
|
|
ott: Union[None, str]
|
|
ott_expire: Union[None, datetime.datetime]
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
application = self.application
|
|
|
|
ott: Union[None, str]
|
|
ott = self.ott
|
|
|
|
ott_expire: Union[None, str]
|
|
if isinstance(self.ott_expire, datetime.datetime):
|
|
ott_expire = self.ott_expire.isoformat()
|
|
else:
|
|
ott_expire = self.ott_expire
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"application": application,
|
|
"ott": ott,
|
|
"ott_expire": ott_expire,
|
|
}
|
|
)
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
application = d.pop("application")
|
|
|
|
def _parse_ott(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
ott = _parse_ott(d.pop("ott"))
|
|
|
|
def _parse_ott_expire(data: object) -> Union[None, datetime.datetime]:
|
|
if data is None:
|
|
return data
|
|
try:
|
|
if not isinstance(data, str):
|
|
raise TypeError()
|
|
ott_expire_type_0 = isoparse(data)
|
|
|
|
return ott_expire_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, datetime.datetime], data)
|
|
|
|
ott_expire = _parse_ott_expire(d.pop("ott_expire"))
|
|
|
|
request_ott = cls(
|
|
application=application,
|
|
ott=ott,
|
|
ott_expire=ott_expire,
|
|
)
|
|
|
|
request_ott.additional_properties = d
|
|
return request_ott
|
|
|
|
@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
|