<%
	def slack_link(url, displayText):
		return f'<{url}|{displayText}>'
## ACCOUNTS
	accounts_text = ''
	accounts = notification['cloud_account_ids']
	if accounts:
	 	accounts_text = f'*Accounts:* {", ".join(accounts)}' if len(accounts) > 1 else f'*Account:* {accounts[0]}'
## TAGS
	tags = notification['tags'].items()
	tags_text = ''
	if tags:
			tags_text = '      '.join([f'*{k}*: {v}' for (k, v) in tags])
## SEVERITY
	severity_data = {
		'CRITICAL': {
			'imgUrl': 'https://downloads-cloudzero-com.s3.amazonaws.com/notifications/sev_critical.png',
			'text': 'Critical'},
		'MAJOR': {
			'imgUrl': 'https://downloads-cloudzero-com.s3.amazonaws.com/notifications/sev_major.png',
			'text': 'Major'},
		'MINOR': {
			'imgUrl': 'https://downloads-cloudzero-com.s3.amazonaws.com/notifications/sev_minor.png',
			'text': 'Minor'},
		'WARNING': {
			'imgUrl': 'https://downloads-cloudzero-com.s3.amazonaws.com/notifications/sev_warning.png',
			'text': 'Warning'},
		'INFORMATION': {
			'imgUrl': 'https://downloads-cloudzero-com.s3.amazonaws.com/notifications/sev_info.png',
			'text': 'Information'},
	}[notification['severity']]
%>

{
	"blocks": [
		{
			"type": "section",
			"block_id": "section567",
			"text": {
				"type": "mrkdwn",
				"text": "*${slack_link(notification['links'][0], notification['title'])}*\n${notification['description']}"
			}
		},
		{
			"type": "divider"
		},
		% if accounts:
		{
			"type": "context",
			"elements": [
				{
					"type": "mrkdwn",
					"text": "${accounts_text}"
				}
			]
		},
		% endif
		% if tags:
			{
				"type": "context",
				"elements": [
					{
						"type": "mrkdwn",
						"text": "${tags_text}"
					}
				]
			},
		% endif
		{
			"type": "context",
			"elements": [
				{
					"type": "image",
					"image_url": "${severity_data['imgUrl']}",
					"alt_text": "${severity_data['text']}"
				},
				{
					"type": "mrkdwn",
					<%
                      from datetime import datetime
                      from dateutil.tz import tzutc
                      formatted_time = datetime.fromtimestamp(float(notification['timestamp']), tz=tzutc()).isoformat()
                    %>
					"text": "*${severity_data['text']}* Type: ${notification['type']} Time: ${formatted_time}"
				}
			]
		}
	]
}
