154 lines
4.8 KiB
Python
154 lines
4.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
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="ApplicationModel")
|
|
|
|
|
|
@_attrs_define
|
|
class ApplicationModel:
|
|
"""The Application holds information about an app which can send notifications.
|
|
|
|
Attributes:
|
|
description (Union[None, str]): The description of the application. Example: Backup server for the interwebs.
|
|
id (int): The application id. Example: 5.
|
|
image (str): The image of the application. Example: image/image.jpeg.
|
|
internal (bool): Whether the application is an internal application. Internal applications should not be
|
|
deleted.
|
|
name (str): The application name. This is how the application should be displayed to the user. Example: Backup
|
|
Server.
|
|
token (str): The application token. Can be used as `appToken`. See Authentication. Example: AWH0wZ5r0Mbac.r.
|
|
default_priority (Union[Unset, int]): The default priority of messages sent by this application. Defaults to 0.
|
|
Example: 4.
|
|
last_used (Union[None, Unset, datetime.datetime]): The last time the application token was used. Example:
|
|
2019-01-01 00:00:00+00:00.
|
|
"""
|
|
|
|
description: Union[None, str]
|
|
id: int
|
|
image: str
|
|
internal: bool
|
|
name: str
|
|
token: str
|
|
default_priority: Union[Unset, int] = UNSET
|
|
last_used: Union[None, Unset, datetime.datetime] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
description: Union[None, str]
|
|
description = self.description
|
|
|
|
id = self.id
|
|
|
|
image = self.image
|
|
|
|
internal = self.internal
|
|
|
|
name = self.name
|
|
|
|
token = self.token
|
|
|
|
default_priority = self.default_priority
|
|
|
|
last_used: Union[None, Unset, str]
|
|
if isinstance(self.last_used, Unset):
|
|
last_used = UNSET
|
|
elif isinstance(self.last_used, datetime.datetime):
|
|
last_used = self.last_used.isoformat()
|
|
else:
|
|
last_used = self.last_used
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"description": description,
|
|
"id": id,
|
|
"image": image,
|
|
"internal": internal,
|
|
"name": name,
|
|
"token": token,
|
|
}
|
|
)
|
|
if default_priority is not UNSET:
|
|
field_dict["defaultPriority"] = default_priority
|
|
if last_used is not UNSET:
|
|
field_dict["lastUsed"] = last_used
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
|
|
def _parse_description(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
description = _parse_description(d.pop("description"))
|
|
|
|
id = d.pop("id")
|
|
|
|
image = d.pop("image")
|
|
|
|
internal = d.pop("internal")
|
|
|
|
name = d.pop("name")
|
|
|
|
token = d.pop("token")
|
|
|
|
default_priority = d.pop("defaultPriority", UNSET)
|
|
|
|
def _parse_last_used(data: object) -> Union[None, Unset, datetime.datetime]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
try:
|
|
if not isinstance(data, str):
|
|
raise TypeError()
|
|
last_used_type_1 = isoparse(data)
|
|
|
|
return last_used_type_1
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, Unset, datetime.datetime], data)
|
|
|
|
last_used = _parse_last_used(d.pop("lastUsed", UNSET))
|
|
|
|
application_model = cls(
|
|
description=description,
|
|
id=id,
|
|
image=image,
|
|
internal=internal,
|
|
name=name,
|
|
token=token,
|
|
default_priority=default_priority,
|
|
last_used=last_used,
|
|
)
|
|
|
|
application_model.additional_properties = d
|
|
return application_model
|
|
|
|
@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
|