139 lines
4.4 KiB
Python
139 lines
4.4 KiB
Python
import datetime
|
|
from collections.abc import Mapping
|
|
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
from dateutil.parser import isoparse
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
if TYPE_CHECKING:
|
|
from ..models.message_external_model_extras import MessageExternalModelExtras
|
|
|
|
|
|
T = TypeVar("T", bound="MessageExternalModel")
|
|
|
|
|
|
@_attrs_define
|
|
class MessageExternalModel:
|
|
"""The MessageExternal holds information about a message which was sent by an Application.
|
|
|
|
Attributes:
|
|
appid (int): The application id that send this message. Example: 5.
|
|
date (datetime.datetime): The date the message was created. Example: 2018-02-27 19:36:10.504504+01:00.
|
|
id (int): The message id. Example: 25.
|
|
message (str): The message. Markdown (excluding html) is allowed. Example: **Backup** was successfully
|
|
finished..
|
|
extras (Union[Unset, MessageExternalModelExtras]): The extra data sent along the message.
|
|
|
|
The extra fields are stored in a key-value scheme. Only accepted in CreateMessage requests with application/json
|
|
content-type.
|
|
|
|
The keys should be in the following format: <top-namespace>::[<sub-namespace>::]<action>
|
|
|
|
These namespaces are reserved and might be used in the official clients: gotify android ios web server client.
|
|
Do not use them for other purposes. Example: {'home::appliances::lighting::on': {'brightness': 15},
|
|
'home::appliances::thermostat::change_temperature': {'temperature': 23}}.
|
|
priority (Union[Unset, int]): The priority of the message. If unset, then the default priority of the
|
|
application will be used. Example: 2.
|
|
title (Union[Unset, str]): The title of the message. Example: Backup.
|
|
"""
|
|
|
|
appid: int
|
|
date: datetime.datetime
|
|
id: int
|
|
message: str
|
|
extras: Union[Unset, "MessageExternalModelExtras"] = UNSET
|
|
priority: Union[Unset, int] = UNSET
|
|
title: Union[Unset, str] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
appid = self.appid
|
|
|
|
date = self.date.isoformat()
|
|
|
|
id = self.id
|
|
|
|
message = self.message
|
|
|
|
extras: Union[Unset, dict[str, Any]] = UNSET
|
|
if not isinstance(self.extras, Unset):
|
|
extras = self.extras.to_dict()
|
|
|
|
priority = self.priority
|
|
|
|
title = self.title
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"appid": appid,
|
|
"date": date,
|
|
"id": id,
|
|
"message": message,
|
|
}
|
|
)
|
|
if extras is not UNSET:
|
|
field_dict["extras"] = extras
|
|
if priority is not UNSET:
|
|
field_dict["priority"] = priority
|
|
if title is not UNSET:
|
|
field_dict["title"] = title
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from ..models.message_external_model_extras import MessageExternalModelExtras
|
|
|
|
d = dict(src_dict)
|
|
appid = d.pop("appid")
|
|
|
|
date = isoparse(d.pop("date"))
|
|
|
|
id = d.pop("id")
|
|
|
|
message = d.pop("message")
|
|
|
|
_extras = d.pop("extras", UNSET)
|
|
extras: Union[Unset, MessageExternalModelExtras]
|
|
if isinstance(_extras, Unset):
|
|
extras = UNSET
|
|
else:
|
|
extras = MessageExternalModelExtras.from_dict(_extras)
|
|
|
|
priority = d.pop("priority", UNSET)
|
|
|
|
title = d.pop("title", UNSET)
|
|
|
|
message_external_model = cls(
|
|
appid=appid,
|
|
date=date,
|
|
id=id,
|
|
message=message,
|
|
extras=extras,
|
|
priority=priority,
|
|
title=title,
|
|
)
|
|
|
|
message_external_model.additional_properties = d
|
|
return message_external_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
|