# Path: doorman/utils.py
# class DateTimeEncoder(json.JSONEncoder):
#     def default(self, o):
#         if isinstance(o, dt.datetime):
#             return o.isoformat()
# 
#         return json.JSONEncoder.default(self, o)
# 
# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


import json
import logging
import requests
from doorman.utils import DateTimeEncoder
from .base import AbstractAlerterPlugin
            count=self.incident_count
        )

        description = match.rule.template.safe_substitute(
            match.result['columns'],
            **node
        ).rstrip()

        description = ":".join(description.split('\r\n\r\n', 1))

        details = {
            'node': node,
            'rule_name': match.rule.name,
            'rule_description': match.rule.description,
            'action': match.result['action'],
            'match': match.result['columns'],
        }

        headers = {
            'Content-type': 'application/json',
        }

        payload = json.dumps({
            'event_type': 'trigger',
            'service_key': self.service_key,
            'incident_key': key,
            'description': description,
            'client': 'Doorman',
            "client_url": self.client_url,
            'details': details,

# Path: doorman/utils.py
# class DateTimeEncoder(json.JSONEncoder):
#     def default(self, o):
#         if isinstance(o, dt.datetime):
#             return o.isoformat()
# 
#         return json.JSONEncoder.default(self, o)
# 
# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


# Path: doorman/plugins/alerters/pagerduty.py
import json
import logging
import requests
from doorman.utils import DateTimeEncoder
from .base import AbstractAlerterPlugin

            count=self.incident_count
        )

        description = match.rule.template.safe_substitute(
            match.result['columns'],
            **node
        ).rstrip()

        description = ":".join(description.split('\r\n\r\n', 1))

        details = {
            'node': node,
            'rule_name': match.rule.name,
            'rule_description': match.rule.description,
            'action': match.result['action'],
            'match': match.result['columns'],
        }

        headers = {
            'Content-type': 'application/json',
        }

        payload = json.dumps({
            'event_type': 'trigger',
            'service_key': self.service_key,
            'incident_key': key,
            'description': description,
            'client': 'Doorman',
            "client_url": self.client_url,
            'details': details,

        }, cls=DateTimeEncoder)