"""Model/object definitions for commonly used types in Irisett.

This modules uses the attrs module to define models for Irisett objects
(monitors, alerts, contacts etc).

The model definitions should exactly match the attributes and order of the
objects in the database.
"""

# noinspection PyPackageRequirements
import attr
# noinspection PyPackageRequirements
from attr import asdict


@attr.s
class ActiveMonitorAlert:
    id = attr.ib()
    monitor_id = attr.ib()
    start_ts = attr.ib()
    end_ts = attr.ib()
    alert_msg = attr.ib()
    model_type = attr.ib(init=False, default='active_monitor_alert')


@attr.s
class Contact:
    id = attr.ib()
    name = attr.ib()
    email = attr.ib()
    phone = attr.ib()
    active = attr.ib()
    model_type = attr.ib(init=False, default='contact')


@attr.s
class ContactGroup:
    id = attr.ib()
    name = attr.ib()
    active = attr.ib()
    model_type = attr.ib(init=False, default='contact_group')


@attr.s
class MonitorGroup:
    id = attr.ib()
    parent_id = attr.ib()
    name = attr.ib()
    model_type = attr.ib(init=False, default='monitor_group')


@attr.s
class ActiveMonitor:
    id = attr.ib()
    def_id = attr.ib()
    state = attr.ib()
    state_ts = attr.ib()
    msg = attr.ib()
    alert_id = attr.ib()
    deleted = attr.ib()
    checks_enabled = attr.ib()
    alerts_enabled = attr.ib()
    model_type = attr.ib(init=False, default='active_monitor')

@@ -386,233 +386,8 @@
 t%0A%0A%0A
-@attr.s%0Aclass ActiveMonitorAlert:%0A    id = attr.ib()%0A    monitor_id = attr.ib()%0A    start_ts = attr.ib()%0A    end_ts = attr.ib()%0A    alert_msg = attr.ib()%0A    model_type = attr.ib(init=False, default='active_monitor_alert')%0A%0A%0A
 @att
@@ -405,16 +405,16 @@
 ontact:%0A
+
     id =
@@ -729,166 +729,8 @@
 )%0A%0A%0A
-@attr.s%0Aclass MonitorGroup:%0A    id = attr.ib()%0A    parent_id = attr.ib()%0A    name = attr.ib()%0A    model_type = attr.ib(init=False, default='monitor_group')%0A%0A%0A
 @att
@@ -966,32 +966,32 @@
 led = attr.ib()%0A
-
     model_type =
@@ -1037,8 +1037,1553 @@
 nitor')%0A
+%0A%0A@attr.s%0Aclass ActiveMonitorArg:%0A    id = attr.ib()%0A    monitor_id = attr.ib()%0A    name = attr.ib()%0A    value = attr.ib()%0A    model_type = attr.ib(init=False, default='active_monitor_arg')%0A%0A%0A@attr.s%0Aclass ActiveMonitorAlert:%0A    id = attr.ib()%0A    monitor_id = attr.ib()%0A    start_ts = attr.ib()%0A    end_ts = attr.ib()%0A    alert_msg = attr.ib()%0A    model_type = attr.ib(init=False, default='active_monitor_alert')%0A%0A%0A@attr.s%0Aclass ActiveMonitorDef:%0A    id = attr.ib()%0A    name = attr.ib()%0A    description = attr.ib()%0A    active = attr.ib()%0A    cmdline_filename = attr.ib()%0A    cmdline_args_tmpl = attr.ib()%0A    description_tmpl = attr.ib()%0A    model_type = attr.ib(init=False, default='active_monitor_arg')%0A%0A%0A@attr.s%0Aclass ActiveMonitorDefArg:%0A    id = attr.ib()%0A    active_monitor_def_id = attr.ib()%0A    name = attr.ib()%0A    display_name = attr.ib()%0A    description = attr.ib()%0A    required = attr.ib()%0A    default_value = attr.ib()%0A    model_type = attr.ib(init=False, default='active_monitor_def_arg')%0A%0A%0A@attr.s%0Aclass ObjectMetadata:%0A    object_type = attr.ib()%0A    object_id = attr.ib()%0A    key = attr.ib()%0A    value = attr.ib()%0A    model_type = attr.ib(init=False, default='object_metadata')%0A%0A%0A@attr.s%0Aclass ObjectBindata:%0A    object_type = attr.ib()%0A    object_id = attr.ib()%0A    key = attr.ib()%0A    value = attr.ib()%0A    model_type = attr.ib(init=False, default='object_bindata')%0A%0A%0A@attr.s%0Aclass MonitorGroup:%0A    id = attr.ib()%0A    parent_id = attr.ib()%0A    name = attr.ib()%0A    model_type = attr.ib(init=False, default='monitor_group')%0A

Create object models for all object types.