-- Copyright (c) 2024 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.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- 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.
-- See the Mulan PSL v2 for more details.

local req_for_bma = cjson.json_object_new_object()
local data = cjson.json_object_new_object()
for _, v in pairs(ReqBody.Members) do
    local monitor_id = v['Id']
    v['Id'] = nil
    data[monitor_id] = v
    if  #data[monitor_id] == 0 then
        data[monitor_id] = nil
    elseif data[monitor_id]['TimerActionStatus'] and #data[monitor_id]['TimerActionStatus'] == 0 then
        data[monitor_id]['TimerActionStatus'] = nil
    end
end
req_for_bma.RequestMethod = 'PATCH'
req_for_bma.RequestUri = '/redfish/v1/Sms/1/Managers/iBMA/Monitors/Overview'
req_for_bma.RequestBody = cjson.json_object_ordered_encode(data)
req_for_bma['If-Match'] = Input

return cjson.json_object_ordered_encode(req_for_bma)
