from typing import Any
from typing import cast
from typing import Dict
from typing import List
from typing import Type
from typing import TypeVar
from typing import Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET
from ..types import Unset
T = TypeVar("T", bound="SMTPSettings")
[docs]
@_attrs_define
class SMTPSettings:
"""SMTPSettings model
Attributes:
enabled (Union[Unset, bool]): Master switch for outbound mail. When false, no notification email is sent
regardless of any per-user preference. Default: False.
from_address (Union[Unset, str]):
host (Union[Unset, str]):
password (Union[None, Unset, str]): Stored and returned in plaintext, as the OAuth and datastore credentials in
this same response already are. Reading it requires the admin.config grant. Credentials are never transmitted
over an unencrypted connection: a username set without use_tls or use_ssl is refused rather than sent in the
clear.
port (Union[Unset, int]): Default: 587.
site_name (Union[Unset, str]): Branding shown in the header and footer of every notification email. Default:
'Delfini'.
use_ssl (Union[Unset, bool]): Use implicit TLS ("SMTPS"), encrypted from the first byte, which is what a relay
on port 465 expects. Mutually exclusive with use_tls. Default: False.
use_tls (Union[Unset, bool]): Use STARTTLS, which is what most relays on port 587 expect. Mutually exclusive
with use_ssl. Default: True.
username (Union[None, Unset, str]):
verify_cert (Union[Unset, bool]): Verify the server's certificate. Turn off only for an internal relay with a
private CA; the connection stays encrypted but is no longer authenticated. Default: True.
"""
enabled: Union[Unset, bool] = False
from_address: Union[Unset, str] = UNSET
host: Union[Unset, str] = UNSET
password: Union[None, Unset, str] = UNSET
port: Union[Unset, int] = 587
site_name: Union[Unset, str] = "Delfini"
use_ssl: Union[Unset, bool] = False
use_tls: Union[Unset, bool] = True
username: Union[None, Unset, str] = UNSET
verify_cert: Union[Unset, bool] = True
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
[docs]
def to_dict(self) -> Dict[str, Any]:
"""Convert to a dict"""
enabled = self.enabled
from_address = self.from_address
host = self.host
password: Union[None, Unset, str]
if isinstance(self.password, Unset):
password = UNSET
else:
password = self.password
port = self.port
site_name = self.site_name
use_ssl = self.use_ssl
use_tls = self.use_tls
username: Union[None, Unset, str]
if isinstance(self.username, Unset):
username = UNSET
else:
username = self.username
verify_cert = self.verify_cert
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if enabled is not UNSET:
field_dict["enabled"] = enabled
if from_address is not UNSET:
field_dict["from_address"] = from_address
if host is not UNSET:
field_dict["host"] = host
if password is not UNSET:
field_dict["password"] = password
if port is not UNSET:
field_dict["port"] = port
if site_name is not UNSET:
field_dict["site_name"] = site_name
if use_ssl is not UNSET:
field_dict["use_ssl"] = use_ssl
if use_tls is not UNSET:
field_dict["use_tls"] = use_tls
if username is not UNSET:
field_dict["username"] = username
if verify_cert is not UNSET:
field_dict["verify_cert"] = verify_cert
return field_dict
[docs]
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
"""Create an instance of :py:class:`SMTPSettings` from a dict"""
d = src_dict.copy()
enabled = d.pop("enabled", UNSET)
from_address = d.pop("from_address", UNSET)
host = d.pop("host", UNSET)
def _parse_password(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
password = _parse_password(d.pop("password", UNSET))
port = d.pop("port", UNSET)
site_name = d.pop("site_name", UNSET)
use_ssl = d.pop("use_ssl", UNSET)
use_tls = d.pop("use_tls", UNSET)
def _parse_username(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
username = _parse_username(d.pop("username", UNSET))
verify_cert = d.pop("verify_cert", UNSET)
smtp_settings = cls(
enabled=enabled,
from_address=from_address,
host=host,
password=password,
port=port,
site_name=site_name,
use_ssl=use_ssl,
use_tls=use_tls,
username=username,
verify_cert=verify_cert,
)
smtp_settings.additional_properties = d
return smtp_settings
@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