-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.

local ret = cjson.json_object_new_object()
ret['Destination'] = Input[1]

if Input[2] ~= nil and Input[2] ~= null then
    ret['EventFormatType'] = Input[2]
end

ret['Context'] = Input[3]
ret['Protocol'] = Input[4]

if Input[5] ~= nil and Input[5] ~= null then
    ret['Severities'] = Input[5] and cjson.json_object_ordered_encode(Input[5])
end
if Input[6] ~= nil and Input[6] ~= null then
    ret['AuthenticationProtocol'] = Input[6]
end
if Input[7] ~= nil and Input[7] ~= null then
    ret['TrapCommunity'] = Input[7]
end
if Input[8] ~= nil and Input[8] ~= null then
    ret['EncryptionProtocol'] = Input[8]
end
if Input[9] ~= nil and Input[9] ~= null then
    ret['AuthenticationKey'] = Input[9]
end
if Input[10] ~= nil and Input[10] ~= null then
    ret['EncryptionKey'] = Input[10]
end
if Input[11] ~= nil and Input[11] ~= null then
    ret['TrapMode'] = Input[11]
end
if Input[12] ~= nil and Input[12] ~= null then
    ret['ServerIdentity'] = Input[12]
end

return ret