# Path: irisett/log.py
# def configure_logging(logtype: str, logfilename: Optional[str]=None, debug_logging: bool=False,
#                       rotate_length: int=1000000, max_rotated_files: int=250) -> None:
# def msg(logmsg: str, section: Optional[str]=None) -> None:
# def debug(logmsg: str, section: Optional[str]=None) -> None:
#     def log_msg(self, logmsg: str) -> None:
#     def log_debug(self, logmsg: str) -> None:
# class LoggingMixin:


from typing import List, Dict, Optional, Any
from irisett import (
    log
)
import aiohttp
import json
import jinja2

async def send_alert_notification(settings: Dict, tmpl_args: Dict):
    attachment = {
        'fallback': settings['tmpl-msg'].render(**tmpl_args),
        'fields': [],
    }
    attachment['pretext'] = attachment['fallback']
    if settings['tmpl-duration']:
        attachment['fields'].append({
            'title': 'Duration',
            'value': settings['tmpl-duration'].render(**tmpl_args),
            'short': False,
        })
    if settings['tmpl-url']:
        attachment['fields'].append({
            'title': 'URL',
            'value': settings['tmpl-url'].render(**tmpl_args),
            'short': False,
        })
    await send_slack_notification(settings['webhook-url'], [attachment])


def parse_settings(config: Any) -> Optional[Dict[str, Any]]:
    ret = {
        'webhook-url': config.get('slack-webhook-url'),
        'tmpl-msg': config.get('slack-tmpl-msg'),
        'tmpl-duration': config.get('slack-tmpl-duration', fallback=''),
        'tmpl-url': config.get('slack-tmpl-url', fallback='')
    }  # type: Any
    if not ret['webhook-url'] or not ret['tmpl-msg']:

# Path: irisett/log.py
# def configure_logging(logtype: str, logfilename: Optional[str]=None, debug_logging: bool=False,
#                       rotate_length: int=1000000, max_rotated_files: int=250) -> None:
# def msg(logmsg: str, section: Optional[str]=None) -> None:
# def debug(logmsg: str, section: Optional[str]=None) -> None:
#     def log_msg(self, logmsg: str) -> None:
#     def log_debug(self, logmsg: str) -> None:
# class LoggingMixin:


# Path: irisett/notify/slack.py
from typing import List, Dict, Optional, Any
from irisett import (
    log
)
import aiohttp
import json
import jinja2


async def send_alert_notification(settings: Dict, tmpl_args: Dict):
    attachment = {
        'fallback': settings['tmpl-msg'].render(**tmpl_args),
        'fields': [],
    }
    attachment['pretext'] = attachment['fallback']
    if settings['tmpl-duration']:
        attachment['fields'].append({
            'title': 'Duration',
            'value': settings['tmpl-duration'].render(**tmpl_args),
            'short': False,
        })
    if settings['tmpl-url']:
        attachment['fields'].append({
            'title': 'URL',
            'value': settings['tmpl-url'].render(**tmpl_args),
            'short': False,
        })
    await send_slack_notification(settings['webhook-url'], [attachment])


def parse_settings(config: Any) -> Optional[Dict[str, Any]]:
    ret = {
        'webhook-url': config.get('slack-webhook-url'),
        'tmpl-msg': config.get('slack-tmpl-msg'),
        'tmpl-duration': config.get('slack-tmpl-duration', fallback=''),
        'tmpl-url': config.get('slack-tmpl-url', fallback='')
    }  # type: Any
    if not ret['webhook-url'] or not ret['tmpl-msg']:

        log.debug('Slack settings missing, no slack notifications will be sent', 'NOTIFICATIONS')