logentries_api/special_alerts.py
def create(self, name, patterns, logs, trigger_config, alert_reports):
        """
        Create an inactivity alert

        :param name: A name for the inactivity alert
        :type name: str

        :param patterns: A list of regexes to match
        :type patterns: list of str

        :param logs: A list of log UUID's. (The 'key' key of a log)
        :type logs: list of str

        :param trigger_config: A AlertTriggerConfig describing how far back to
            look for inactivity.
        :type trigger_config: :class:`AlertTriggerConfig<logentries_api.special_alerts.AlertTriggerConfig>`

        :param alert_reports: A list of AlertReportConfigs to send alerts to
        :type alert_reports: list of
            :class:`AlertReportConfig<logentries_api.special_alerts.AlertReportConfig>`

        :return: The API response
        :rtype: dict

        :raises: This will raise a
            :class:`ServerException<logentries_api.exceptions.ServerException>`
            if there is an error from Logentries
        """
        data = {
            'tag': {
                'actions': [
                    alert_report.to_dict()
                    for alert_report
                    in alert_reports
                ],
                'name': name,
                'patterns': patterns,
                'sources': [
                    {'id': log}
                    for log
                    in logs
                ],
                'sub_type': 'InactivityAlert',
                'type': 'AlertNotify'
            }
        }
        data['tag'].update(trigger_config.to_dict())

        return self._api_post(
            url=self.url_template.format(account_id=self.account_id),
            data=json.dumps(data, sort_keys=True)
        )
def create(self, name, patterns, logs, trigger_config, alert_reports):
        """
        Create an inactivity alert

        :param name: A name for the inactivity alert
        :type name: str

        :param patterns: A list of regexes to match
        :type patterns: list of str

        :param logs: A list of log UUID's. (The 'key' key of a log)
        :type logs: list of str

        :param trigger_config: A AlertTriggerConfig describing how far back to
            look for inactivity.
        :type trigger_config: :class:`AlertTriggerConfig<logentries_api.special_alerts.AlertTriggerConfig>`

        :param alert_reports: A list of AlertReportConfigs to send alerts to
        :type alert_reports: list of
            :class:`AlertReportConfig<logentries_api.special_alerts.AlertReportConfig>`

        :return: The API response
        :rtype: dict

        :raises: This will raise a
            :class:`ServerException<logentries_api.exceptions.ServerException>`
            if there is an error from Logentries
        """
        data = {
            'tag': {
                'actions': [
                    alert_report.to_dict()
                    for alert_report
                    in alert_reports
                ],
                'name': name,
                'patterns': patterns,
                'sources': [
                    {'id': log}
                    for log
                    in logs
                ],
                'sub_type': 'InactivityAlert',
                'type': 'AlertNotify'
            }
        }
        data['tag'].update(trigger_config.to_dict())

        return self._api_post(
            url=self.url_template.format(account_id=self.account_id),
            data=json.dumps(data, sort_keys=True)
        )
Create an inactivity alert

        :param name: A name for the inactivity alert
        :type name: str

        :param patterns: A list of regexes to match
        :type patterns: list of str

        :param logs: A list of log UUID's. (The 'key' key of a log)
        :type logs: list of str

        :param trigger_config: A AlertTriggerConfig describing how far back to
            look for inactivity.
        :type trigger_config: :class:`AlertTriggerConfig<logentries_api.special_alerts.AlertTriggerConfig>`

        :param alert_reports: A list of AlertReportConfigs to send alerts to
        :type alert_reports: list of
            :class:`AlertReportConfig<logentries_api.special_alerts.AlertReportConfig>`

        :return: The API response
        :rtype: dict

        :raises: This will raise a
            :class:`ServerException<logentries_api.exceptions.ServerException>`
            if there is an error from Logentries