{
    "zabbix_export": {
        "version": "6.4",
        "media_types": [
            {
                "name": "ReZa",
                "type": "WEBHOOK",
                "parameters": [
                    {
                        "name": "protocol",
                        "value": "http"
                    },
                    {
                        "name": "fully_qualified_name",
                        "value": "localhost"
                    },
                    {
                        "name": "port",
                        "value": "4338"
                    },
                    {
                        "name": "proxy",
                        "value": ""
                    },
                    {
                        "name": "send_to",
                        "value": "{ALERT.SENDTO}"
                    },
                    {
                        "name": "host_id",
                        "value": "{HOST.ID}"
                    },
                    {
                        "name": "event_id",
                        "value": "{EVENT.ID}"
                    },
                    {
                        "name": "severity",
                        "value": "{EVENT.NSEVERITY}"
                    },
                    {
                        "name": "message",
                        "value": "{ALERT.MESSAGE}"
                    },
                    {
                        "name": "title",
                        "value": "{ALERT.SUBJECT}"
                    }
                ],
                "script": "try {\n    Zabbix.log(4, '[ ReZa ] Starting to send push notification');\n\n    var params = JSON.parse(value);\n    var payload = {\n        \"token\": params.send_to.split(\"===\")[1],\n        \"rsaKey\": params.send_to.split(\"===\")[0],\n        \"notification\": {\n            \"data\": {\n                \"host_id\": params.host_id,\n                \"event_id\": params.event_id,\n                \"severity\": params.severity\n            },\n            \"message\": {                \n                \"title\": params.title,\n                \"message\": params.message,\n            }\n        }\n    };\n\n    Zabbix.log(4, '[ ReZa ] Sending request');\n    var request = new HttpRequest();\n    request.addHeader('Content-Type: application/json');\n    request.setProxy(params.proxy);\n\n    var data = JSON.stringify(payload);\n    var endpoint = params.protocol + \"://\" + params.fully_qualified_name + \":\" + params.port + \"/send\";\n    var response = request.post(endpoint, data);\n    if (response === null) {\n        throw 'Unknown error. Check debug log for more information.';\n    }\n    Zabbix.log(4, '[ ReZa ] Received response with status code ' + request.getStatus() + '\\n' + response);\n\n    if (request.getStatus() != 200) {\n        var parsedResponse;\n        try {\n            parsedResponse = JSON.parse(response);\n        }\n        catch (error) {\n            Zabbix.log(4, '[ ReZa ] Failed to parse response');\n            throw 'Unknown error. Check debug log for more information.';\n        }\n\n        throw parsedResponse;\n    }\n\n    Zabbix.log(4, '[ ReZa ] Finished to send push notification without errors');\n    return 'OK';\n}\ncatch (error) {\n    Zabbix.log(4, '[ ReZa ] Failed to send push notification: ' + error);\n    throw 'Zabbix app notification failed: ' + error;\n}",
                "description": "Please refer to the ReZa integration documentation on https://www.reza.de/plugin for more information.",
                "message_templates": [
                    {
                        "event_source": "TRIGGERS",
                        "operation_mode": "PROBLEM",
                        "subject": "Problem: {EVENT.NAME}",
                        "message": "Problem started at {EVENT.TIME} on {EVENT.DATE}\nHost: {HOST.NAME}\nSeverity: {EVENT.SEVERITY}\nOperational data: {EVENT.OPDATA}\nOriginal problem ID: {EVENT.ID}\n{TRIGGER.URL}"
                    },
                    {
                        "event_source": "TRIGGERS",
                        "operation_mode": "RECOVERY",
                        "subject": "Resolved: {EVENT.NAME}",
                        "message": "Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}\nProblem duration: {EVENT.DURATION}\nHost: {HOST.NAME}\nSeverity: {EVENT.SEVERITY}\nOriginal problem ID: {EVENT.ID}\n{TRIGGER.URL}"
                    },
                    {
                        "event_source": "TRIGGERS",
                        "operation_mode": "UPDATE",
                        "subject": "Updated problem in {EVENT.AGE}: {EVENT.NAME}",
                        "message": "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.\n{EVENT.UPDATE.MESSAGE}\n\nCurrent problem status is {EVENT.STATUS}, age is {EVENT.AGE}, acknowledged: {EVENT.ACK.STATUS}."
                    }
                ]
            }
        ]
    }
}