# Path: moira_client/client.py
# class ResponseStructureError(Exception):
#     def __init__(self, msg, content):
#         """
# 
#         :param msg: str error message
#         :param content: dict response content
#         """
#         self.msg = msg
#         self.content = content
# 
# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content
# 
# Path: moira_client/models/base.py
# class Base:
#     @property
#     def id(self):
#         return self._id
# 
#     def __repr__(self):
#         return '({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __unicode__(self):
#         return u'({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __eq__(self, other):
#         return self.id == other.id
# 
#     def __ne__(self, other):
#         return self.id != other.id
# 
# Path: moira_client/models/common.py
# MINUTES_IN_HOUR = 60
# 
# def get_schedule(start_hour, start_minute, end_hour, end_minute, disabled_days):
#     days = []
#     for day in DAYS_OF_WEEK:
#         day_info = {
#             'enabled': True if day not in disabled_days else False,
#             'name': day
#         }
#         days.append(day_info)
#     return {
#         'days': days,
#         'startOffset': start_hour * MINUTES_IN_HOUR + start_minute,
#         'endOffset': end_hour * MINUTES_IN_HOUR + end_minute,
#     }


from ..client import ResponseStructureError
from ..client import InvalidJSONError
from .base import Base
from .common import MINUTES_IN_HOUR, get_schedule

        self._id = kwargs.get('id', None)
        self.name = name
        self.tags = tags
        self.targets = targets
        self.warn_value = warn_value
        self.error_value = error_value
        self.desc = desc
        self.ttl = ttl
        self.ttl_state = ttl_state
        
        default_sched = {
            'startOffset': 0,
            'endOffset': 1439,
            'tzOffset': 0
        }
        if not sched:
            sched = default_sched
            self.disabled_days = set()
        else:
            if 'days' in sched:
                self.disabled_days = {day['name'] for day in sched['days'] if not day['enabled']}
        self.sched = sched
        self.expression = expression
        self.trigger_type = self.resolve_type(trigger_type)

        # compute time range
        self._start_hour = self.sched['startOffset'] // MINUTES_IN_HOUR
        self._start_minute = self.sched['startOffset'] - self._start_hour * MINUTES_IN_HOUR
        self._end_hour = self.sched['endOffset'] // MINUTES_IN_HOUR

# Path: moira_client/client.py
# class ResponseStructureError(Exception):
#     def __init__(self, msg, content):
#         """
# 
#         :param msg: str error message
#         :param content: dict response content
#         """
#         self.msg = msg
#         self.content = content
# 
# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content
# 
# Path: moira_client/models/base.py
# class Base:
#     @property
#     def id(self):
#         return self._id
# 
#     def __repr__(self):
#         return '({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __unicode__(self):
#         return u'({} {})'.format(self.__class__.__name__, self.id)
# 
#     def __eq__(self, other):
#         return self.id == other.id
# 
#     def __ne__(self, other):
#         return self.id != other.id
# 
# Path: moira_client/models/common.py
# MINUTES_IN_HOUR = 60
# 
# def get_schedule(start_hour, start_minute, end_hour, end_minute, disabled_days):
#     days = []
#     for day in DAYS_OF_WEEK:
#         day_info = {
#             'enabled': True if day not in disabled_days else False,
#             'name': day
#         }
#         days.append(day_info)
#     return {
#         'days': days,
#         'startOffset': start_hour * MINUTES_IN_HOUR + start_minute,
#         'endOffset': end_hour * MINUTES_IN_HOUR + end_minute,
#     }


# Path: moira_client/models/trigger.py
from ..client import ResponseStructureError
from ..client import InvalidJSONError
from .base import Base
from .common import MINUTES_IN_HOUR, get_schedule


        self._id = kwargs.get('id', None)
        self.name = name
        self.tags = tags
        self.targets = targets
        self.warn_value = warn_value
        self.error_value = error_value
        self.desc = desc
        self.ttl = ttl
        self.ttl_state = ttl_state
        
        default_sched = {
            'startOffset': 0,
            'endOffset': 1439,
            'tzOffset': 0
        }
        if not sched:
            sched = default_sched
            self.disabled_days = set()
        else:
            if 'days' in sched:
                self.disabled_days = {day['name'] for day in sched['days'] if not day['enabled']}
        self.sched = sched
        self.expression = expression
        self.trigger_type = self.resolve_type(trigger_type)

        # compute time range
        self._start_hour = self.sched['startOffset'] // MINUTES_IN_HOUR
        self._start_minute = self.sched['startOffset'] - self._start_hour * MINUTES_IN_HOUR
        self._end_hour = self.sched['endOffset'] // MINUTES_IN_HOUR

        self._end_minute = self.sched['endOffset'] - self._end_hour * MINUTES_IN_HOUR